-
Notifications
You must be signed in to change notification settings - Fork 2k
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
tests: Fix thread return with local message queue #17502
tests: Fix thread return with local message queue #17502
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I think the arrays could be static
, couldn't they?
(I'm aware it is style and subjective, but a blank line before a function makes it IMO easier to spot where the function starts. Feel free to ignore, if you disagree.)
Yes they can be static, and probably should (not that it'd matter a lot in the test applications); going with your newlines as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK. The change is unscary enough to go in without testing. Please squash :)
When a message queue is configured from the stack, that main function must never return -- otherwise, during sched_task_exit (which the thread's function "returns" to), message senders might still send messages into already freed stack space (which would be reused by sched_task_exit). Co-authored-by: Marian Buschsieweke <maribu@users.noreply.github.com>
12c8d63
to
b4a1851
Compare
No need for a second ACK IMO. If you insist on a 2nd ACK, speak up now. |
Contribution description
When a message queue is configured from the stack, that main function
must never return -- otherwise, during sched_task_exit (which the
thread's function "returns" to), message senders might still send
messages into already freed stack space (which would be reused by
sched_task_exit).
[new] A follow-up commit adds a line on this to the msg_init_queue documentation.
Most occurrences of queue initialization throughout RIOT are either static or followed by an endless loop without breaks / returns; the few examples not matching either pattern are fixed here.
Testing procedure
I don't see any way to make the fixed behavior actually happen; this is more about best practice. (Especially given that sched_task_exit currently starts with a debug statement followed by
irq_disable
, so the message would need to hit right into the execution of debug printing).The two altered tesets that don't depend on hardware can be and were successfully run (in tests/thread_msg_block_w_queue and tests/posix_semaphore) on native.
Issues/PRs references
This came up when nailing down the safety criteria of
msg_init_queue
in Rust.[edit: see [new]]