-
Notifications
You must be signed in to change notification settings - Fork 891
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
Crash on [AWSMQTTSession publishDataAtLeastOnce:onTopic:retain:onMessageIdResolved:] when running publish and subscribe actions sequentially #5497
Comments
Thank you for posting this. We're glad that you have a workaround at the moment.
|
Hi, the crash rarely occurs while the Thread Sanitizer on Xcode almost always reports the race condition situation I reported above. I'll leave you below all the logs I managed to get out:
|
Thanks for the info. At this moment we are unable to reproduce this issue in a local isolated environment. That being said, we will still investigate and validate if we can find a root cause. |
Describe the bug
A crash occurs due to a race condition in the [AWSMQTTSession publishDataAtLeastOnce:onTopic:retain:onMessageIdResolved:] function. The issue is caused by concurrent access to the ackCallbackDictionary when running publish and subscribe actions sequentially.
To Reproduce
Steps to reproduce the behavior:
There is no fixed reproducibility procedure, and crashes occur at irregular intervals but these are the steps I followed:
Observed Behavior
There are two functions involved:
-session:newAckForMessageId:
msgId
is returned on a background thread.ackCallbackDictionary
(AWSMQTTSession publishDataAtLeastOnce:onTopic:retain:onMessageIdResolved:)
:msgId
is generated and added toackCallbackDictionary
with its callback.Since both methods access
ackCallbackDictionary
on different threads without protection, concurrent access may occur.Stack Trace
**Areas of the SDK you are using **
AWS IoT
Screenshots
Environment:
Device Information (please complete the following information):
Solution
I created a fork where I modified the removal of the ack from the dictionary before calling the callback. This is a temporary workaround to avoid immediate issues, but a permanent fix would require changes to the concurrency management in the AWSIoT library, such as using appropriate synchronization mechanisms for access to the
ackCallbackDictionary
.Link
The text was updated successfully, but these errors were encountered: