Skip to content

Abort() while HAPAccessoryServerStop #11

@CrowdedFuzzball

Description

@CrowdedFuzzball

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

Fault	assertion failed - HAPPlatformLogPOSIXError @ ../esp-apple-homekit-adk/port/src/HAPPlatformLog.c:65
abort() was called at PC 0x400d673f on core 0
0x400d673f: _exit at ../esp-idf/components/newlib/syscalls.c:67

0x40090188: invoke_abort at ../esp-idf/components/esp32/panic.c:159
0x40090539: abort at ../esp-idf/components/esp32/panic.c:174
0x400d673f: _exit at ../esp-idf/components/newlib/syscalls.c:67
0x401d452a: exit at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/newlib/newlib/libc/stdlib/exit.c:64
0x4010e049: HAPPlatformAbort at ../esp-apple-homekit-adk/port/src/HAPPlatformAbort.c:27
0x40100454: HAPAssertInternal at ../esp-apple-homekit-adk/homekit_adk/PAL/HAPAssert.c:20
0x4010e286: HAPPlatformLogPOSIXError at ../esp-apple-homekit-adk/port/src/HAPPlatformLog.c:65 (discriminator 2)
0x400ffde5: HAPPlatformTCPStreamManagerCloseListener at ../esp-apple-homekit-adk/port/src/HAPPlatformTCPStreamManager.c:332
0x40106f5c: schedule_max_idle_time_timer at ../esp-apple-homekit-adk/homekit_adk/HAP/HAPIPAccessoryServer.c:389
0x40108e0a: handle_server_state_transition_timer at ../esp-apple-homekit-adk/homekit_adk/HAP/HAPIPAccessoryServer.c:3874
0x400ff601: ProcessExpiredTimers at ../esp-apple-homekit-adk/port/src/HAPPlatformRunLoop.c:381
 (inlined by) HAPPlatformRunLoopRun at ../esp-apple-homekit-adk/port/src/HAPPlatformRunLoop.c:638
0x40084d20: HomeKit::Task(void*) at /src/HomeKit/HomeKit.cpp:271

Error occurs here:

    HAPLogDebug(&logObject, "shutdown(%d, SHUT_RDWR);", tcpStreamManager->tcpStreamListener.fileDescriptor);
    e = shutdown(tcpStreamManager->tcpStreamListener.fileDescriptor, SHUT_RDWR);
    if (e != 0) {
        int _errno = errno;
        HAPAssert(e == -1);
        HAPPlatformLogPOSIXError(
                kHAPLogType_Debug,
                "System call 'shutdown' on TCP stream listener socket failed.",
                _errno,
                __func__,
                HAP_FILE,
                __LINE__);
    }

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions