fix(trainer): potential crash when SBUS trainer is used - #7696
Open
3djc wants to merge 1 commit into
Open
Conversation
…rainer The SBUS trainer receive context is a single pair of globals in sbus.cpp, shared between the aux serial port and the external module trainer, but trainer_stop_module_sbus() never released it. modulePortDeInit() zeroes the underlying serial state, so the context was left dangling: the next IDLE IRQ on the aux port dereferenced a null sp, read a garbage USART pointer and faulted, ending in a watchdog reset (emergency mode). Reaching it only takes scrolling the trainer mode field to Master/Serial, which passes through Master/SBUS module on the way. Release the context when the module trainer stops, claim it back for the aux port when entering Master/Serial, and reject a stale context in the STM32 serial driver entry points and IRQ handler. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CGM5RJHayqfqviwX5o7oKQ
Member
Nice 🥳 ... I think this is something we have been playing wack-a-mole with in the past and may have been on on raphael's mile long todo list to fix but never happened |
Contributor
|
Very cool! Great job ;-) Wasn't there also a problem with not setting up pull-up/pull-down properly? |
Collaborator
Author
|
No, I checked all our radio and serial, they are handled the same way. It is very likely just the not so easy to identify process to trigger that was in fault, not the antenna wire |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The SBUS trainer receive context is a single pair of globals in sbus.cpp, shared between the aux serial port and the external module trainer, but trainer_stop_module_sbus() never released it. modulePortDeInit() zeroes the underlying serial state, so the context was left dangling: the next IDLE IRQ on the aux port dereferenced a null sp, read a garbage USART pointer and faulted, ending in a watchdog reset (emergency mode).
This fixes it
Fixes #7644