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

-[AWSIoTStreamThread main] EXC_BREAKPOINT

Open ad-Jun opened this issue 7 months ago • 8 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: [iPhone15 Pro]
  • 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: 2df413d1d5c8f75c4f68c61519616807
# Session: 3c05ac473d9c4b1e8a5b527ffe306cd4_DNE_0_v2
# Date: Wed May 07 2025 11:18:38 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() + 4377241036 (<compiler-generated>:4377241036)
12 xxxx-RM-iOS                   0xe6c1e0 static AppDelegate.$main() + 4377231840 (<compiler-generated>:4377231840)
13 xxxx-RM-iOS                   0xe6e3c4 main + 40 (AppDelegate.swift:40)
14 ???                            0x1b60ffad8 (缺少)

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

com.squareup.SocketRocket.NetworkThread
0  libsystem_kernel.dylib         0xaf8 __ulock_wait2 + 8
1  libsystem_platform.dylib       0x3204 _os_unfair_lock_lock_slow + 176
2  CoreFoundation                 0x8d94 _CFStreamClose + 220
3  AWSIoT                         0x8ba5c -[AWSSRWebSocket _cleanupSelfReference:] + 1245 (AWSSRWebSocket.m:1245)
4  Foundation                     0x1da140 __NSFireTimer + 96
5  CoreFoundation                 0x94654 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 32
6  CoreFoundation                 0x94314 __CFRunLoopDoTimer + 980
7  CoreFoundation                 0x93e8c __CFRunLoopDoTimers + 288
8  CoreFoundation                 0x7102c __CFRunLoopRun + 1848
9  CoreFoundation                 0x95700 CFRunLoopRunSpecific + 572
10 Foundation                     0x748a8 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
11 AWSIoT                         0x8d5a0 -[_SRRunLoopThread main] + 1905 (AWSSRWebSocket.m:1905)
12 Foundation                     0x115cf8 __NSThread__start__ + 732
13 libsystem_pthread.dylib        0x1afc _pthread_start + 136
14 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

Crashed: Thread
0  CoreFoundation                 0xea20 CF_IS_OBJC + 64
1  CoreFoundation                 0xfda48 _signalEventSync + 88
2  CoreFoundation                 0xfd97c _cfstream_shared_signalEventSync + 392
3  CoreFoundation                 0x72ce4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
4  CoreFoundation                 0x72c78 __CFRunLoopDoSource0 + 172
5  CoreFoundation                 0x719fc __CFRunLoopDoSources0 + 232
6  CoreFoundation                 0x70c3c __CFRunLoopRun + 840
7  CoreFoundation                 0x95700 CFRunLoopRunSpecific + 572
8  Foundation                     0x748a8 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
9  AWSIoT                         0x8140c -[AWSIoTStreamThread main] + 98 (AWSIoTStreamThread.m:98)
10 Foundation                     0x115cf8 __NSThread__start__ + 732
11 libsystem_pthread.dylib        0x1afc _pthread_start + 136
12 libsystem_pthread.dylib        0x1a04 thread_start + 8

com.apple.root.default-qos
0  libsystem_kernel.dylib         0x6f18 __psynch_mutexwait + 8
1  libsystem_pthread.dylib        0x3a50 _pthread_mutex_firstfit_lock_wait + 84
2  libsystem_pthread.dylib        0x3698 _pthread_mutex_firstfit_lock_slow + 220
3  CoreFoundation                 0x8e84 _CFStreamClose + 460
4  AWSIoT                         0x60230 -[AWSIoTMQTTClient cleanUpWebsocketOutputStream] + 714 (AWSIoTMQTTClient.m:714)
5  AWSIoT                         0x63988 -[AWSIoTMQTTClient webSocket:didCloseWithCode:reason:wasClean:] + 1303 (AWSIoTMQTTClient.m:1303)
6  AWSIoT                         0x8cc94 __41-[AWSSRWebSocket safeHandleEvent:stream:]_block_invoke_2 + 1595 (AWSSRWebSocket.m:1595)
7  libdispatch.dylib              0x1aac _dispatch_call_block_and_release + 32
8  libdispatch.dylib              0x1b584 _dispatch_client_callout + 16
9  libdispatch.dylib              0x3725c _dispatch_queue_override_invoke.cold.3 + 32
10 libdispatch.dylib              0x61f8 _dispatch_queue_override_invoke + 848
11 libdispatch.dylib              0x13db0 _dispatch_root_queue_drain + 364
12 libdispatch.dylib              0x1454c _dispatch_worker_thread2 + 156
13 libsystem_pthread.dylib        0x4624 _pthread_wqthread + 232
14 libsystem_pthread.dylib        0x19f8 start_wqthread + 8

Thread
0  libsystem_pthread.dylib        0x19f0 start_wqthread + 142

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

com.apple.root.default-qos
0  libsystem_kernel.dylib         0x6f18 __psynch_mutexwait + 8
1  libsystem_pthread.dylib        0x3a50 _pthread_mutex_firstfit_lock_wait + 84
2  libsystem_pthread.dylib        0x3698 _pthread_mutex_firstfit_lock_slow + 220
3  CoreFoundation                 0xfd070 _CFStreamCopyRunLoopsAndModes + 40
4  CoreFoundation                 0xfc998 _wakeWriteStreamScheduledRunLoops + 20
5  CoreFoundation                 0xfc938 boundPairWrite + 452
6  CoreFoundation                 0x24228 CFWriteStreamWrite + 312
7  AWSIoT                         0x637e0 -[AWSIoTMQTTClient webSocket:didReceiveMessage:] + 1290 (AWSIoTMQTTClient.m:1290)
8  AWSIoT                         0x8a944 __33-[AWSSRWebSocket _handleMessage:]_block_invoke + 836 (AWSSRWebSocket.m:836)
9  libdispatch.dylib              0x1aac _dispatch_call_block_and_release + 32
10 libdispatch.dylib              0x1b584 _dispatch_client_callout + 16
11 libdispatch.dylib              0x3725c _dispatch_queue_override_invoke.cold.3 + 32
12 libdispatch.dylib              0x61f8 _dispatch_queue_override_invoke + 848
13 libdispatch.dylib              0x13db0 _dispatch_root_queue_drain + 364
14 libdispatch.dylib              0x1454c _dispatch_worker_thread2 + 156
15 libsystem_pthread.dylib        0x4624 _pthread_wqthread + 232
16 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

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

Hi, I'll write this to avoid creating two tickets for the same issue. Feel free to remove it if you believe this does not bring more details to this issue.

This crash is our top1 and top2 crashs in our project. I believe they're similar, since they both crash in "cleanUp" function. They always crash while the app is in background.

I can share the log of thread crashing:

 Crashed: com.apple.root.default-qos
0  CoreFoundation                 0x32d8 CF_IS_OBJC + 12
1  CoreFoundation                 0x36f70 _CFStreamClose + 260
2  AWSIoT                         0xad7c -[AWSIoTMQTTClient cleanUpWebsocketOutputStream] + 710 (AWSIoTMQTTClient.m:710)
3  AWSIoT                         0xe4f4 -[AWSIoTMQTTClient webSocket:didCloseWithCode:reason:wasClean:] + 1299 (AWSIoTMQTTClient.m:1299)
4  AWSIoT                         0x87490 __41-[AWSSRWebSocket safeHandleEvent:stream:]_block_invoke_2 + 1595 (AWSSRWebSocket.m:1595)
5  libdispatch.dylib              0x1aac _dispatch_call_block_and_release + 32
6  libdispatch.dylib              0x1b584 _dispatch_client_callout + 16
7  libdispatch.dylib              0x37288 _dispatch_queue_override_invoke.cold.3 + 32
8  libdispatch.dylib              0x61f8 _dispatch_queue_override_invoke + 848
9  libdispatch.dylib              0x13db0 _dispatch_root_queue_drain + 364
10 libdispatch.dylib              0x1454c _dispatch_worker_thread2 + 156
11 libsystem_pthread.dylib        0x9d0 _pthread_wqthread + 232
12 libsystem_pthread.dylib        0xaac start_wqthread + 8

and

          Crashed: com.amazonaws.iot.streamthread.syncQueue
0  CoreFoundation                 0x3178 CF_IS_OBJC + 12
1  CoreFoundation                 0xee4fc _CFStreamUnscheduleFromRunLoop + 188
2  AWSIoT                         0x90e00 __29-[AWSIoTStreamThread cleanUp]_block_invoke + 154 (AWSIoTStreamThread.m:154)
3  libdispatch.dylib              0x1b584 _dispatch_client_callout + 16
4  libdispatch.dylib              0x11728 _dispatch_lane_barrier_sync_invoke_and_complete + 56
5  AWSIoT                         0x90bdc -[AWSIoTStreamThread cleanUp] + 133 (AWSIoTStreamThread.m:133)
6  AWSIoT                         0x90534 -[AWSIoTStreamThread main] + 104 (AWSIoTStreamThread.m:104)
7  Foundation                     0x75804 __NSThread__start__ + 732
8  libsystem_pthread.dylib        0x3344 _pthread_start + 136
9  libsystem_pthread.dylib        0xab8 thread_start + 8

ffroehly avatar Jun 25 '25 09:06 ffroehly

@ffroehly Is using our newer version of the IoT library written in Swift an option for you? https://github.com/aws/aws-iot-device-sdk-swift/

harsh62 avatar Jun 25 '25 13:06 harsh62

@harsh62 Hi, for the moment, we do not plan on switching version, especially not since it's in 0.x You guys are still maintaining "aws-sdk-ios" ? Or is it your way of saying that this crash might not be fixed ?

ffroehly avatar Jun 25 '25 14:06 ffroehly

@ffroehly There have been several attempts to fix crashes on AWSIoT and have been unsuccessful. The issue is not reproducible in a local developer environment which makes it even more difficult. At this time it feels like a rewrite of the core logic would be the best way forward, which is already happening in the Swift library that is being introduced.

I can give it another try based on the crash logs you have shared. But I won't be able to guarantee that a fix would completely resolve the issue.

harsh62 avatar Jun 25 '25 14:06 harsh62

A try is all we need ! As a developer, I know it is really annoying to chase a bug/crash without being able to test it.

It'd be really nice of you to get a look at it. And if you don't find anything, that's that. We'll have to switch eventually.

ffroehly avatar Jun 25 '25 14:06 ffroehly