-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abort() while HAPAccessoryServerStop #11
Comments
I'm not sure about the problem in the code you quoted, but I think there's a bug in HAPPlatformLogPOSIXError that causes the assert to fail. The POSIX version of strerror_r returns a string, but the code calling it is written for the XSI version, which return an error code (int). |
Looking a little more carefully at HAPPlatformLog.c, I see there is a compiler guard in there to prevent compiling if the wrong strerror_r is used. (Who thought it would be a good idea to change the signature of stderror_r, anyway?) So I'm not exactly sure what's going on. But it definitely looks like strerror_r is returning a pointer, not an int, at least for me. This means it always fails the assert on line 67: HAPAssert(e == ERANGE); But you're seeing an assert on line 65, and if you're using the same version of code as me, that means your strerror_r is returning EINVAL. So the that means on your system, one problem is HAPStringWithFormat is returning an error, and another problem is that the error number passed to HAPPlatformLogPOSIXError is not valid. Either way, the asserts should not fail, and you should not see an abort. But this is sort of a side discussion. The primary problem you're seeing is that shutdown returns an error, and I don't have an answer for that. |
@
Got it, thanks for the clarification. I don't know if it helps or not, but the compilation takes place on OSX, it is likely that HAPPlatformLogPOSIXError gives an incorrect value in this particular operating system. |
Got same problem with my code. Well, HAPPlatformLog.c contains this code:
as @baysinger mentioned before we already have guards to prevent such problem. so commenting out
Anyway I looked into assembler of
it looks exactly like this version https://github.com/espressif/newlib-esp32/blob/422607527f8d7543701e83812950153ba2a8e9c0/newlib/libc/string/strerror_r.c#L68 |
Thanks @izmmisha, your pull request seems to work for me. No more crashes! |
Hello!
In some cases, stopping the accessory server can be helpful.
For example, if you have Bridge.
To update the list of devices working through the bridge, Apple recommends using the HAPAccessoryServerStop function and then restarting through the HAPAccessoryServerStartBridge.
Unfortunately, in this fork, when trying to stop the server, the following error occurs:
After invoke HAPAccessoryServerStop(BridgeAccessoryConfiguration.server) inside scheduled callback
Error occurs here:
If commented this lines - everything is ok except of memory leaks and i think it is not a good behaviour.
Could you please inspect this issue?
The text was updated successfully, but these errors were encountered: