• 赚钱入口【需求资源】限时招募流量主、渠道主,站长合作;【合作模式】CPS长期分成,一次推广永久有收益。主动打款,不扣量;

IoTHubClient_LL_DoWork() crash ios14

iOS cps12345 3个月前 (09-08) 144次浏览 0个评论

更新到iOS 14后,只要碰到IoTHubClient_LL_DoWork()就会出现一样的crash

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString objectForKey:]: unrecognized selector sent to instance 0x7fff801abf28'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff20438fda __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff2017712e objc_exception_throw + 48
2 CoreFoundation 0x00007fff20447b29 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
3 CoreFoundation 0x00007fff2043d510 forwarding + 1479
4 CoreFoundation 0x00007fff2043f548 _CF_forwarding_prep_0 + 120
5 CFNetwork 0x00007fff235bfa29 _CFStreamErrorFromCFError + 216339
6 CFNetwork 0x00007fff235b67cd _CFStreamErrorFromCFError + 178871
7 CoreFoundation 0x00007fff203c88bf CFReadStreamSetProperty + 93
8 AzureIoTUtility 0x000000010da5a848 dowork_poll_socket + 136
9 AzureIoTUtility 0x000000010da5a183 tlsio_appleios_dowork + 179
10 AzureIoTUtility 0x000000010da66f04 xio_dowork + 52
11 AzureIoTuMqtt 0x000000010db1f0c3 mqtt_client_dowork + 115
12 AzureIoTHubClient 0x000000010d99de7e IoTHubTransport_MQTT_Common_DoWork + 1038
13 AzureIoTHubClient 0x000000010d9ae905 IoTHubTransportMqtt_DoWork + 21
14 AzureIoTHubClient 0x000000010d96e581 IoTHubClientCore_LL_DoWork + 337
15 AzureIoTHubClient 0x000000010d972da5 IoTHubClient_LL_DoWork + 21
16 Locate2u 0x000000010cf58b31 $s8Locate2u22ServerMessagingServiceC6doworkyyF + 33
17 Locate2u 0x000000010cf58b6b $s8Locate2u22ServerMessagingServiceC6doworkyyFTo + 43
18 Foundation 0x00007fff2086e90c __NSFireTimer + 67
19 CoreFoundation 0x00007fff203a7ed4 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 20
20 CoreFoundation 0x00007fff203a79a7 __CFRunLoopDoTimer + 926
21 CoreFoundation 0x00007fff203a6f5a __CFRunLoopDoTimers + 265
22 CoreFoundation 0x00007fff203a15e8 __CFRunLoopRun + 1949
23 CoreFoundation 0x00007fff203a0960 CFRunLoopRunSpecific + 567
24 GraphicsServices 0x00007fff2b9e7db3 GSEventRunModal + 139
25 UIKitCore 0x00007fff245f5bd9 -[UIApplication _run] + 912
26 UIKitCore 0x00007fff245faaea UIApplicationMain + 101
27 Locate2u 0x000000010cf7f21b main + 75
28 libdyld.dylib 0x00007fff20256431 start + 1
29 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString objectForKey:]: unrecognized selector sent to instance 0x7fff801abf28'
terminating with uncaught exception of type NSException
CoreSimulator 732.10 - Device: iPhone 11 Pro 14 (81C14598-2ABC-4BF2-9064-51EF9C9A31B0) - Runtime: iOS 14.0 (18A5342e) - DeviceType: iPhone 11 Pro
This process is running with libgmalloc.dylib (GuardMalloc) which may have forced the crash due to a memory access error.

解决

需要Dictionary。替换以下代码

static void dowork_poll_socket(TLS_IO_INSTANCE* tls_io_instance)
{
// This will pretty much only fail if we run out of memory

CFStreamCreatePairWithSocketToHost(NULL, tls_io_instance->hostname, tls_io_instance->port, &tls_io_instance->sockRead, &tls_io_instance->sockWrite);

if (tls_io_instance->sockRead != NULL && tls_io_instance->sockWrite != NULL)
{
    
    // Micha Edits
    
    CFStringRef keys[1] = {kCFStreamPropertySocketSecurityLevel};
    CFStringRef values[1] = {kCFStreamSocketSecurityLevelNegotiatedSSL};

    CFDictionaryRef test = CFDictionaryCreate(NULL , (void *)keys , (void *)values , 1,  NULL , NULL);
    
    if (CFReadStreamSetProperty(tls_io_instance->sockRead, kCFStreamPropertySSLSettings, test))

    //if (CFReadStreamSetProperty(tls_io_instance->sockRead, kCFStreamPropertySSLSettings, kCFStreamSocketSecurityLevelNegotiatedSSL))
    {
        tls_io_instance->tlsio_state = TLSIO_STATE_OPENING_WAITING_SSL;
    }
    else
    {
        LogError("Failed to set socket properties");
        enter_open_error_state(tls_io_instance);
    }
    
    CFRelease(test);
}
else
{
    LogError("Unable to create socket pair");
    enter_open_error_state(tls_io_instance);
}
}

另外,用于IoTHubClient的最新CocoaPod是:pod’AzureIoTHubClient’,’= 1.3.9-LTS’。尽管cocoapods网站是较新的,但它可能仍未指向该网站

喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址