Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWSMQTTSession error and crash my app after encode or decode. #4978

Closed
yukitaka13-1110 opened this issue Oct 2, 2023 · 5 comments
Closed
Labels
bug Something isn't working iot Issues related to the IoT SDK

Comments

@yukitaka13-1110
Copy link

Describe the bug
This crash will be the one reported by the user operation. I have not been able to reproduce it. From the crash report, it appears that an out of memory range access occurred within AWSMQTTSession. However, I have not been able to determine why it occurs. I believe it is due to something other than these three occurrences in the error case.

  • AWSMQTTDecoderEventConnectionClosed
  • AWSMQTTDecoderEventConnectionError
  • AWSMQTTDecoderEventProtocolError

To Reproduce
I have not been able to identify a reproducible procedure. From looking at the user logs I would expect it to happen when the app is moved to the background and then restored.

Observed Behavior
Crash my app.

Expected Behavior
Prevent to crash my app.

Stack Trace

Case 1

EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000

Crashed: Thread
0  CoreFoundation                 0x77994 CFArrayGetCount + 8
1  CoreFoundation                 0x403a8 _CFStreamClose + 260
2  AWSIoT                         0x7a63c -[AWSMQTTEncoder close] + 132
3  AWSIoT                         0x7e618 -[AWSMQTTSession error:] + 136
4  AWSIoT                         0x7a160 -[AWSMQTTDecoder stream:handleEvent:] + 532
5  CoreFoundation                 0xf95dc _signalEventSync + 212
6  CoreFoundation                 0x67db4 _cfstream_shared_signalEventSync + 444
7  CoreFoundation                 0xcc288 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
8  CoreFoundation                 0xd7be8 __CFRunLoopDoSource0 + 172
9  CoreFoundation                 0x61f48 __CFRunLoopDoSources0 + 232
10 CoreFoundation                 0x76f74 __CFRunLoopRun + 780
11 CoreFoundation                 0x7bb48 CFRunLoopRunSpecific + 584
12 Foundation                     0x3e168 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 208
13 AWSIoT                         0x5b27c -[AWSIoTMQTTClient openStreams:] + 472
14 Foundation                     0x55ca4 __NSThread__start__ + 704
15 libsystem_pthread.dylib        0x3060 _pthread_start + 116
16 libsystem_pthread.dylib        0x1688 thread_start + 8

Case 2

com.apple.main-thread
0  libsystem_kernel.dylib         0xca4 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0x13b74 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0x13e4c mach_msg_overwrite + 540
3  libsystem_kernel.dylib         0x11e8 mach_msg + 24
4  CoreFoundation                 0x79024 __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x7a250 __CFRunLoopRun + 1208
6  CoreFoundation                 0x7f3ec CFRunLoopRunSpecific + 612
7  GraphicsServices               0x135c GSEventRunModal + 164
8  UIKitCore                      0x39cf58 -[UIApplication _run] + 888
9  UIKitCore                      0x39cbbc UIApplicationMain + 340
10 Runner                         0x6bc4 main + 7 (AppDelegate.swift:7)
11 ???                            0x1d9d14dec (シンボルが不足しています)

Thread
0  libsystem_kernel.dylib         0x1164 __semwait_signal + 8
1  libsystem_c.dylib              0x5888 nanosleep + 220
2  libsystem_c.dylib              0x6554 usleep + 68
3  AWSIoT                         0x7e64c -[AWSMQTTSession error:] + 188
4  AWSIoT                         0x7a160 -[AWSMQTTDecoder stream:handleEvent:] + 532
5  CoreFoundation                 0x1034b8 _signalEventSync + 216
6  CoreFoundation                 0x6a76c _cfstream_shared_signalEventSync + 392
7  CoreFoundation                 0xd3128 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
8  CoreFoundation                 0xdf7b4 __CFRunLoopDoSource0 + 176
9  CoreFoundation                 0x645e8 __CFRunLoopDoSources0 + 244
10 CoreFoundation                 0x7a0d4 __CFRunLoopRun + 828
11 CoreFoundation                 0x7f3ec CFRunLoopRunSpecific + 612
12 Foundation                     0x41fb4 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
13 AWSIoT                         0x5b27c -[AWSIoTMQTTClient openStreams:] + 472
14 Foundation                     0x5b524 __NSThread__start__ + 716
15 libsystem_pthread.dylib        0x16b8 _pthread_start + 148
16 libsystem_pthread.dylib        0xb88 thread_start + 8

Code Snippet
Please provide a snippet of the code causing the issue or how you are using the service that has the bug.

Unique Configuration
If you are reporting an issue with a unique configuration or where configuration can make a difference in code execution (i.e. Cognito) please provide your configuration. Please make sure to obfuscate sensitive information from the configuration before posting.

Areas of the SDK you are using (AWSMobileClient, Cognito, Pinpoint, IoT, etc)?

- AWSAuthCore (2.32.0):
    - AWSCore (= 2.32.0)
  - AWSCognitoIdentityProvider (2.32.0):
    - AWSCognitoIdentityProviderASF (= 2.32.0)
    - AWSCore (= 2.32.0)
  - AWSCognitoIdentityProviderASF (2.32.0):
    - AWSCore (= 2.32.0)
  - AWSCore (2.32.0)
  - AWSIoT (2.32.0):
    - AWSCore (= 2.32.0)
  - AWSMobileClient (2.32.0):
    - AWSAuthCore (= 2.32.0)
    - AWSCognitoIdentityProvider (= 2.32.0)
    - AWSCognitoIdentityProviderASF (= 2.32.0)
    - AWSCore (= 2.32.0)

Screenshots
If applicable, add screenshots to help explain your problem.

Environment(please complete the following information):

  • SDK Version: ?
  • Dependency Manager: Cocoapods
  • Swift Version : 4.0
  • Xcode Version: 14.0.1

Device Information (please complete the following information):

  • Device: [iPhone SE 2nd, iPhone 8]
  • iOS Version: [iOS 16.6.1, 16.3.1]

Additional context
Add any other context about the problem here like your specific use case.

Relevant Console Output
In some cases, it might be helpful to add any logs from your console that better help you tell the story of this issue. You can easily enable logging in your app by putting the following code in your app delegate.

AWSDDLog.sharedInstance.logLevel = .debug
AWSDDLog.add(AWSDDTTYLogger.sharedInstance)

Logs

Please logs in the code block below. (See: Logs Guidance)

Log Messages
INSERT LOG MESSAGES HERE
@harsh62 harsh62 added bug Something isn't working iot Issues related to the IoT SDK labels Oct 3, 2023
@harsh62
Copy link
Member

harsh62 commented Oct 3, 2023

@yukitaka13-1110 Thanks you for raising the issue. Our team will look into the issue and provide an update as soon as we can.

@yukitaka13-1110
Copy link
Author

@harsh62 Hi! Do you have any updates about this?

@yukitaka13-1110
Copy link
Author

yukitaka13-1110 commented Oct 25, 2023

@harsh62 We encountered another crash.

Crashed: com.apple.root.default-qos
0  CoreFoundation                 0xd4dc CFArrayGetCount + 16
1  CoreFoundation                 0x1a978 _CFStreamClose + 264
2  AWSIoT                         0x5dff8 -[AWSIoTMQTTClient webSocket:didCloseWithCode:reason:wasClean:] + 196
3  AWSIoT                         0x8378c __41-[AWSSRWebSocket safeHandleEvent:stream:]_block_invoke_2 + 112
4  libdispatch.dylib              0x2924 _dispatch_call_block_and_release + 32
5  libdispatch.dylib              0x4670 _dispatch_client_callout + 20
6  libdispatch.dylib              0x7798 _dispatch_queue_override_invoke + 792
7  libdispatch.dylib              0x15de0 _dispatch_root_queue_drain + 396
8  libdispatch.dylib              0x16608 _dispatch_worker_thread2 + 164
9  libsystem_pthread.dylib        0x10b8 _pthread_wqthread + 228
10 libsystem_pthread.dylib        0xe94 start_wqthread + 8
iOS Version: iosiPadOS 15.3.1
Device Model:iPad (9th generation)

- AWSAuthCore (2.32.0):
    - AWSCore (= 2.32.0)
  - AWSCognitoIdentityProvider (2.32.0):
    - AWSCognitoIdentityProviderASF (= 2.32.0)
    - AWSCore (= 2.32.0)
  - AWSCognitoIdentityProviderASF (2.32.0):
    - AWSCore (= 2.32.0)
  - AWSCore (2.32.0)
  - AWSIoT (2.32.0):
    - AWSCore (= 2.32.0)
  - AWSMobileClient (2.32.0):
    - AWSAuthCore (= 2.32.0)
    - AWSCognitoIdentityProvider (= 2.32.0)
    - AWSCognitoIdentityProviderASF (= 2.32.0)
    - AWSCore (= 2.32.0)

@naresh-kumar-ios
Copy link

Hi everyone, I was also facing the same issue. I checked AWSMobileClient from version 2.28.0 to 2.33.0. This is happening in all versions. After lot of struggle and no updated from AWS, I observer, the Mqtt is making a queue of data we are publishing. And if we have lot of data pending to be published in that queue and then connection fluctuate then this crash is happening.
So I created a mechanism where I am syncing the data one by one, means once acknowledgement of one packet is received then only send another one. There after I didn't faced this crash at all.
The following versions I am using right now -

AWSMobileClient - 2.33.4
AWSIoT - 2.33.4
OpenSSL-Universal - 1.1.1501
Xcode - 14.3.1
Swift - 5

@lawmicha
Copy link
Contributor

lawmicha commented Feb 9, 2024

Hello, we released 2.33.9 which includes an IoT crash fix #5185. Please upgrade to this and let us know if you are still experiencing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working iot Issues related to the IoT SDK
Projects
None yet
Development

No branches or pull requests

5 participants