aws-sdk-ios icon indicating copy to clipboard operation
aws-sdk-ios copied to clipboard

-[AWSIoTMQTTClient webSocket:didFailWithError:] EXC_BAD_ACCESS (KERN_INVALID_ADDRESS)

Open ad-Jun opened this issue 7 months ago • 3 comments

Describe the bug This crash occurred frequently online.I utilized the crash stack information monitored by firebase.

Environment(please complete the following information):

  • SDK Version: [2.40.2]
  • Dependency Manager: [Cocoapods]
  • Swift Version : [6.0]
  • Xcode Version: [16.2]

Device Information (please complete the following information):

  • Device: [iPhone13]
  • iOS Version: [iOS 18.4.1]
  • Specific to simulators:

INSERT LOG MESSAGES HERE

# Crashlytics - Stack trace
# Application: com.xxxx.xxxx
# Platform: apple
# Version: 2.2.1 (202504282015)
# Issue: 21458489debe4a8f6c440b84d1af5ecf
# Session: fa96f6f91b40483687167bf8293b0a6e_DNE_0_v2
# Date: Wed May 07 2025 08:06:42 GMT+0800 (中国标准时间)

com.apple.main-thread
0  libsystem_kernel.dylib         0xce4 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x439c mach_msg2_internal + 76
2  libsystem_kernel.dylib         0x42b8 mach_msg_overwrite + 428
3  libsystem_kernel.dylib         0x4100 mach_msg + 24
4  CoreFoundation                 0x716cc __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x70dac __CFRunLoopRun + 1208
6  CoreFoundation                 0x95700 CFRunLoopRunSpecific + 572
7  GraphicsServices               0x1190 GSEventRunModal + 168
8  UIKitCore                      0x3ca240 -[UIApplication _run] + 816
9  UIKitCore                      0x3c8470 UIApplicationMain + 336
10 UIKitCore                      0x826a30 block_destroy_helper.15 + 9820
11 xxxx-RM-iOS                   0xe6e5cc static UIApplicationDelegate.main() + 4359529932 (<compiler-generated>:4359529932)
12 xxxx-RM-iOS                   0xe6c1e0 static AppDelegate.$main() + 4359520736 (<compiler-generated>:4359520736)
13 xxxx-RM-iOS                   0xe6e3c4 main + 40 (AppDelegate.swift:40)
14 ???                            0x1b8c4bad8 (缺少)

com.apple.uikit.eventfetch-thread
0  libsystem_kernel.dylib         0xce4 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x439c mach_msg2_internal + 76
2  libsystem_kernel.dylib         0x42b8 mach_msg_overwrite + 428
3  libsystem_kernel.dylib         0x4100 mach_msg + 24
4  CoreFoundation                 0x716cc __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x70dac __CFRunLoopRun + 1208
6  CoreFoundation                 0x95700 CFRunLoopRunSpecific + 572
7  Foundation                     0x748a8 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
8  Foundation                     0x736d8 -[NSRunLoop(NSRunLoop) runUntilDate:] + 64
9  UIKitCore                      0x4bd5ec -[UIEventFetcher threadMain] + 424
10 Foundation                     0x115cf8 __NSThread__start__ + 732
11 libsystem_pthread.dylib        0x1afc _pthread_start + 136
12 libsystem_pthread.dylib        0x1a04 thread_start + 8

com.google.firebase.crashlytics.MachExceptionServer
0  FirebaseCrashlytics            0x1dc08 FIRCLSProcessRecordAllThreads + 392 (FIRCLSProcess.c:392)
1  FirebaseCrashlytics            0x1e014 FIRCLSProcessRecordAllThreads + 423 (FIRCLSProcess.c:423)
2  FirebaseCrashlytics            0x14df8 FIRCLSHandler + 34 (FIRCLSHandler.m:34)
3  FirebaseCrashlytics            0x17994 FIRCLSMachExceptionServer + 521 (FIRCLSMachException.c:521)
4  libsystem_pthread.dylib        0x1afc _pthread_start + 136
5  libsystem_pthread.dylib        0x1a04 thread_start + 8

com.apple.NSURLConnectionLoader
0  libsystem_kernel.dylib         0xce4 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x439c mach_msg2_internal + 76
2  libsystem_kernel.dylib         0x42b8 mach_msg_overwrite + 428
3  libsystem_kernel.dylib         0x4100 mach_msg + 24
4  CoreFoundation                 0x716cc __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x70dac __CFRunLoopRun + 1208
6  CoreFoundation                 0x95700 CFRunLoopRunSpecific + 572
7  CFNetwork                      0xebeec +[__CFN_CoreSchedulingSetRunnable _run:] + 416
8  Foundation                     0x115cf8 __NSThread__start__ + 732
9  libsystem_pthread.dylib        0x1afc _pthread_start + 136
10 libsystem_pthread.dylib        0x1a04 thread_start + 8

Thread
0  libsystem_kernel.dylib         0xc60 semaphore_wait_trap + 8
1  libdispatch.dylib              0x38e0 _dispatch_sema4_wait + 28
2  libdispatch.dylib              0x3e90 _dispatch_semaphore_wait_slow + 132
3  UIKitCore                      0x5a5d58 CGSizeFromString + 24900
4  UIKitCore                      0xe0e24 -[UISceneLayerPresentationContext alpha] + 744
5  Foundation                     0x115cf8 __NSThread__start__ + 732
6  libsystem_pthread.dylib        0x1afc _pthread_start + 136
7  libsystem_pthread.dylib        0x1a04 thread_start + 8

com.squareup.SocketRocket.NetworkThread
0  libsystem_kernel.dylib         0xce4 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x439c mach_msg2_internal + 76
2  libsystem_kernel.dylib         0x42b8 mach_msg_overwrite + 428
3  libsystem_kernel.dylib         0x4100 mach_msg + 24
4  CoreFoundation                 0x716cc __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x70dac __CFRunLoopRun + 1208
6  CoreFoundation                 0x95700 CFRunLoopRunSpecific + 572
7  Foundation                     0x748a8 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
8  AWSIoT                         0x8d5a0 -[_SRRunLoopThread main] + 1905 (AWSSRWebSocket.m:1905)
9  Foundation                     0x115cf8 __NSThread__start__ + 732
10 libsystem_pthread.dylib        0x1afc _pthread_start + 136
11 libsystem_pthread.dylib        0x1a04 thread_start + 8

com.apple.CFSocket.private
0  libsystem_kernel.dylib         0x832c select$DARWIN_EXTSN + 8
1  libsystem_kernel.dylib         0x832c __select + 8
2  CoreFoundation                 0xc8b84 __CFSocketManager + 704
3  libsystem_pthread.dylib        0x1afc _pthread_start + 136
4  libsystem_pthread.dylib        0x1a04 thread_start + 8

Thread
0  libsystem_kernel.dylib         0xa90 __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x46ac _pthread_wqthread + 368
2  libsystem_pthread.dylib        0x19f8 start_wqthread + 8

Thread
0  libsystem_kernel.dylib         0xa90 __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x46ac _pthread_wqthread + 368
2  libsystem_pthread.dylib        0x19f8 start_wqthread + 8

Thread
0  libsystem_kernel.dylib         0x6658 __semwait_signal + 8
1  libsystem_c.dylib              0x1c3e8 nanosleep + 220
2  libsystem_c.dylib              0x1c300 usleep + 68
3  AWSIoT                         0x875e0 -[AWSMQTTSession error:] + 663 (AWSMQTTSession.m:663)
4  AWSIoT                         0x8298c -[AWSMQTTDecoder stream:handleEvent:] + 165 (AWSMQTTDecoder.m:165)
5  CoreFoundation                 0x13e914 _inputStreamCallbackFunc + 72
6  CoreFoundation                 0xfdac4 _signalEventSync + 212
7  CoreFoundation                 0xfd97c _cfstream_shared_signalEventSync + 392
8  CoreFoundation                 0x72ce4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
9  CoreFoundation                 0x72c78 __CFRunLoopDoSource0 + 172
10 CoreFoundation                 0x719fc __CFRunLoopDoSources0 + 232
11 CoreFoundation                 0x70c3c __CFRunLoopRun + 840
12 CoreFoundation                 0x95700 CFRunLoopRunSpecific + 572
13 Foundation                     0x748a8 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
14 AWSIoT                         0x8140c -[AWSIoTStreamThread main] + 98 (AWSIoTStreamThread.m:98)
15 Foundation                     0x115cf8 __NSThread__start__ + 732
16 libsystem_pthread.dylib        0x1afc _pthread_start + 136
17 libsystem_pthread.dylib        0x1a04 thread_start + 8

Thread
0  libsystem_kernel.dylib         0xa90 __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x46ac _pthread_wqthread + 368
2  libsystem_pthread.dylib        0x19f8 start_wqthread + 8

Thread
0  libsystem_kernel.dylib         0xa90 __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x46ac _pthread_wqthread + 368
2  libsystem_pthread.dylib        0x19f8 start_wqthread + 8

Thread
0  libsystem_kernel.dylib         0xa90 __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x46ac _pthread_wqthread + 368
2  libsystem_pthread.dylib        0x19f8 start_wqthread + 8

Thread
0  libsystem_kernel.dylib         0xa90 __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x46ac _pthread_wqthread + 368
2  libsystem_pthread.dylib        0x19f8 start_wqthread + 8

Thread
0  libsystem_kernel.dylib         0xa90 __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x46ac _pthread_wqthread + 368
2  libsystem_pthread.dylib        0x19f8 start_wqthread + 8

Crashed: com.apple.root.default-qos
0  CoreFoundation                 0xe9ec CF_IS_OBJC + 12
1  CoreFoundation                 0x8dbc _CFStreamClose + 260
2  AWSIoT                         0x635b8 -[AWSIoTMQTTClient webSocket:didFailWithError:] + 1265 (AWSIoTMQTTClient.m:1265)
3  AWSIoT                         0x8a3e4 __33-[AWSSRWebSocket _failWithError:]_block_invoke_2 + 759 (AWSSRWebSocket.m:759)
4  libdispatch.dylib              0x1aac _dispatch_call_block_and_release + 32
5  libdispatch.dylib              0x1b584 _dispatch_client_callout + 16
6  libdispatch.dylib              0x3725c _dispatch_queue_override_invoke.cold.3 + 32
7  libdispatch.dylib              0x61f8 _dispatch_queue_override_invoke + 848
8  libdispatch.dylib              0x13db0 _dispatch_root_queue_drain + 364
9  libdispatch.dylib              0x1454c _dispatch_worker_thread2 + 156
10 libsystem_pthread.dylib        0x4624 _pthread_wqthread + 232
11 libsystem_pthread.dylib        0x19f8 start_wqthread + 8

ad-Jun avatar May 08 '25 03:05 ad-Jun

Hello, thank you for posting this. We have tried to release several improvements in previous releases. However, we have not been successful in reproducing the issue on our side. Would you be able to share a mini project/code that helps us reproduce this issue?

thisisabhash avatar May 08 '25 16:05 thisisabhash

We found that when we actively called the disconnect method of AWSIoTDataManager, the probability of these crashes occurring would increase significantly. Hope this is helpful for you to analyze the occurrence of bugs. In addition, when I call the AWSIoTDataManager disconnect method, I'll call the reconnection connectUsingWebSocketWithClientId, whether this would be the cause of the crash occurred probability high?

ad-Jun avatar May 28 '25 07:05 ad-Jun

Thank you for the extra information. We are looking into it.

tylerjroach avatar Jun 02 '25 19:06 tylerjroach