novastone-media / MQTT-Client-Framework

iOS, macOS, tvOS native ObjectiveC MQTT Client Framework
Other
1.84k stars 459 forks source link

-[MQTTDecoder stream:handleEvent:] Crash #580

Closed wuqingzheng closed 3 years ago

wuqingzheng commented 3 years ago

Thank you very much for your developed [MQTT Client - Framework] (https://github.com/novastone-media/MQTT-Client-Framework), we are trying to use it, but shows the firebase crash a lot.

The version we used before was 0.9.2, and there were many crashes after going online, so we checked the issue and found the issue [#325](-[MQTTDecoder stream:handleEvent:] crashing with EXC_BAD_ACCESS KERN_INVALID_ADDRESS #325)

0 libobjc.A.dylib   objc_msgSend + 24
1 XXXX  0x0000000104dc4000 + 19064952
2 CoreFoundation    __signalEventSync + 216
3 CoreFoundation    __cfstream_shared_signalEventSync + 380
4 CoreFoundation    ___CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
5 CoreFoundation    ___CFRunLoopDoSource0 + 208
6 CoreFoundation    ___CFRunLoopDoSources0 + 268
7 CoreFoundation    ___CFRunLoopRun + 824
8 CoreFoundation    CFRunLoopRunSpecific + 600
9 GraphicsServices  GSEventRunModal + 164
10 UIKitCore    -[UIApplication _run] + 1072
11 UIKitCore    UIApplicationMain + 168
12 XXXX Graph<float, float, float>::process_source_orphan(Graph<float, float, float>::node*) + 11207880
13 libdyld.dylib    _start + 4

Therefore, we chose to update the version. Due to the change of interface, we chose to update to version 0.10.0, but there were still very, very many Crashes.

0 libobjc.A.dylib   objc_msgSend + 20
1 XXXX  0x0000000102ff8000 + 19066052
2 CoreFoundation    __signalEventSync + 212
3 CoreFoundation    ____signalEventQueue_block_invoke + 24
4 libdispatch.dylib __dispatch_call_block_and_release + 24
5 libdispatch.dylib __dispatch_client_callout + 16
6 libdispatch.dylib __dispatch_main_queue_callback_4CF$VARIANT$armv81 + 856
7 CoreFoundation    ___CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
8 CoreFoundation    ___CFRunLoopRun + 2480
9 CoreFoundation    CFRunLoopRunSpecific + 572
10 GraphicsServices GSEventRunModal + 160
11 UIKitCore    -[UIApplication _run] + 1052
12 UIKitCore    UIApplicationMain + 164
13 XXXX Graph<float, float, float>::process_source_orphan(Graph<float, float, float>::node*) + 11207476
14 libdyld.dylib    _start + 4

Then, we found that the [Add fix for crash when decoder deallocated] (https://github.com/robnadin/MQTT-Client-Framework/commit/de8982dad71da98fa6de98b00535bb81c8f3f4a8), so finally have been solved this problem? If we update to 0.15.3, will we not Crash?

wuqingzheng commented 3 years ago

When building a connection, if the MQTTDecoder receives an incorrect message or code, it will be thrown to the business through the delegate. If reconnected at this point, the MQTTDecoder is reinitialized, and it is possible to release the MQTTDecoder, resulting in an access-wild pointer Crash.

The latest version has been modified here to address this issue, 3Q