cpu/native: fix lockup on libucontext#21915
Merged
maribu merged 1 commit intoRIOT-OS:masterfrom Nov 26, 2025
Merged
Conversation
crasbe
reviewed
Nov 25, 2025
mguetschow
approved these changes
Nov 26, 2025
Contributor
mguetschow
left a comment
There was a problem hiding this comment.
I have reproduced the bug with the patched tinybuild-native64 from RIOT-OS/riotdocker#259 (comment) using BUILD_IN_DOCKER=1 DOCKER_IMAGE=local/tinybuild-native64:latest make -C tests/core/irq all test.
With the changes from this PR applied, both this one and tests/core/mutex_cancel successfully complete.
Thanks for finding and fixing! I haven't looked much into the changes themselves though, being quite unfamiliar with native context switching, trusting your expertise here.
The `setcontext()` implementation of glibc does restore the signal mask to the target thread during the switch, libucontext [does not][1] [1]: https://man.archlinux.org/man/libucontext.3.en#CAVEATS Instead, we just manually enable signals again just before the call to `setcontext()`. With this, tests like `tests/core/mutex_canel` or `tests/core/irq` now pass on `native64` when using libucontext. Co-authored-by: crasbe <crasbe@gmail.com>
1aa87c4 to
87af1a4
Compare
This was referenced Nov 26, 2025
Member
Author
|
Thx ❤️ |
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.
Contribution description
The
setcontext()implementation of glibc does restore the signal mask to the target thread during the switch, libucontext does notInstead, we just manually enable signals again just before the call to
setcontext().With this, tests like
tests/core/mutex_canelortests/core/irqnow pass onnative64when using libucontext.Testing procedure
Run
On
mastere.g. using Alpine LinuxThis PR
Issues/PRs references
None