MQTT-Client-Framework
MQTT-Client-Framework copied to clipboard
EXC_BAD_ACCESS (SIGSEGV),Help!
Device Info
pod 'MQTTClient', '~> 0.15.3'
Xcode Version 12.5 (12E262)
MacOS 11.3 (20E232)
Crash Info
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x000003d290848018
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [11573]
-[MQTTSSLSecurityPolicyEncoder stream:handleEvent:] (in XiaoP) (MQTTSSLSecurityPolicyEncoder.m:58)
-[MQTTDecoder close] (in XiaoP) (MQTTDecoder.m:87)
-[MQTTDecoder dealloc] (in XiaoP) (MQTTDecoder.m:31)
-[MQTTSession connect] (in XiaoP) (MQTTSession.m:1547)
-[XYMQTTManager _connectAndResetRetryInterval:] (in XiaoP) (XYMQTTManager.m:565)
__22-[XYMQTTManager start]_block_invoke (in XiaoP) (XYMQTTManager.m:163)
-[ReconnectTimer reconnect] (in XiaoP) (ReconnectTimer.m:64)
I found that there is a corresponding fix in MQTTDecoder,But there is no such fix in MQTTCFSocketDecoder and MQTTCFSocketEncoder
MQTTDecoder.m
- (void)stream:(NSStream *)sender handleEvent:(NSStreamEvent)eventCode {
// We contact our delegate, MQTTSession at some point in this method
// This call can cause MQTTSession to dealloc and thus, MQTTDecoder to dealloc
// So we end up with invalid object in the middle of the method
// To prevent this we retain self for duration of this method call
MQTTDecoder *strongDecoder = self;
(void)strongDecoder;
.....
}