-
-
Notifications
You must be signed in to change notification settings - Fork 116
[AtModem] Fix NullReferenceException in AtChannel.ProcessMessage #1221
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
[AtModem] Fix NullReferenceException in AtChannel.ProcessMessage #1221
Conversation
The _currentCommand and the _currentResponse are used troughout the AtChannel class. They are set to null in the 'finally' of the AtChannel.SendFullCommand. But in very few occasions (once every hour or so) the _currentCommand is used by another thread after it has been set to null, resulting in a NullReferenceException. For example in HandleFinalResponse. This is the same multi-threading problem like the one fixed in PR nanoframework#1216. We can fix this by placing a lock around the call to AtChannel.ProcessMessage so access to _currentCommand and _currentresponse is mutually exclusive to setting them to null. So NullReference cannot occur. Signed-off-by: Rik Kreeftenberg <rik.kreeftenberg@spinsoft.nl> #1579
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Description
The _currentCommand and the _currentResponse are used troughout the AtChannel class. They are set to null in the 'finally' of the AtChannel.SendFullCommand. But in very few occasions (once every hour or so) the _currentCommand is used by another thread after it has been set to null, resulting in a NullReferenceException. For example in HandleFinalResponse. This is the same multi-threading problem like the one fixed in PR #1216.
We can fix this by placing a lock around the call to AtChannel.ProcessMessage so access to _currentCommand and _currentresponse is mutually exclusive to setting them to null. So NullReference cannot occur.
This also discussed with @Ellerbach in https://discord.com/channels/478725473862549535/1320052446227071116/1323303047895449642
Signed-off-by: Rik Kreeftenberg rik.kreeftenberg@spinsoft.nl
Motivation and Context
This fixes the last NullreferenceException that I came accross during my testing of the AtModem library.
How Has This Been Tested?
I have tested this by POST'ing thousands of messages to an Azure Function app for a day and checking if there are any uncaught exceptions written to a logfile created by connecting Putty to the debug port. There weren't.. ;-)
Screenshots
Types of changes
Checklist: