-
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
fix: correctly cleaning up the websocket stream #5482
fix: correctly cleaning up the websocket stream #5482
Conversation
@awsmobilesdk Hi guys, anyone can help take a look at this PR? Currently the corresponding issues are causing many app crashes, but I am not sure if my change makes sense, please help confirm, thanks. |
@ruisebas @thisisabhash Could you help take a look at this PR? |
Hi @zhouzh1, thanks for opening this PR! Unfortunately, the validations you've added will not prevent concurrency issues/crashes, since they can still be accessed by multiple threads at the same time. However, we've recently added several concurrency checks in version 2.38.1 that might prevent your crashes. Would you mind checking that version up? If after upgrading you're still getting crashes, please submit an issue and provide the full symbolicated crashlog and we'll take a look. Thanks! |
@ruisebas Thanks for the reply, I will retry the |
The problem is that even with your changes, the streams For example, you've added these checks for the value of (stream.streamStatus != NSStreamStatusNotOpen && stream.streamStatus != NSStreamStatusClosed) Let's say the status is But right at that same time, another Thread B attempts to close the stream. The check will still resolve to |
@ruisebas What you said above definitely make sense, so the checks I added include the check for the |
It's the same situation, two threads could read the Having said that, I don't think your changes would cause new issues, actually they could help reduce the concurrency troubles. But they don't really properly fix the underlying problem. Are you still getting crashes/issues with the changes implemented in version 2.38.1? |
@ruisebas Thanks for the reply, and I agree with what you said that my changes aren't able to 100% resolve the issue, I haven't really tried the 2.38.1 yet, because my new version of the app hasn't been released yet, as for why I keep asking that, it's because of I reviewed the relevant code, seems that the 2.38.1 still couldn't totally eliminate those concurrency issues, but anyway, that's just my suspicion, so let me try it at first, if it doesn't help, I will try to improve my changes and ship them by patching way. |
Issue #, if available:
None
Description of changes:
![image](https://private-user-images.githubusercontent.com/21986828/397700854-be283271-e538-4764-abdf-6cea6df540eb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNzUyOTgsIm5iZiI6MTczOTE3NDk5OCwicGF0aCI6Ii8yMTk4NjgyOC8zOTc3MDA4NTQtYmUyODMyNzEtZTUzOC00NzY0LWFiZGYtNmNlYTZkZjU0MGViLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDA4MDk1OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTczN2MyMjE0ODczZTRkYzJkNzk4MTU1YjY5NDVlYTcxMjQ0MWYzNDExNzI2MTM3N2NhMWMxZDJkMTc3YTc0MDcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.hjTVmEkzozNvkegyHN9DJayV_edQrPi3Q46QW7cAd1w)
The issue we're suffering from:
Currently we found there're many crashes in our iOS app which are related to the
AWSIoT
lib when it's cleaning up the websocket streams, after dig into the relevant source code, I think the possible reason for those crashes is that the lib code doesn't put enough consideration for the situation where the created websocket stream is shared by mutiple threads, meanwhile, more than one thread have the method to perform the cleaning job for that websocket stream, and moreover, they don't check the stream status, that would cause the same websocket stream to be cleaned more than one time, then the app crash happens. The below screenshot shows some crash reports.The changes implemented in this PR
Check points:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.