Repository navigation
fix/futex: forget to .await in futex_exit - #63
Open
greatbridf wants to merge 1 commit into
Open
greatbridf wants to merge 1 commit into
greatbridf wants to merge 1 commit into
Conversation
Testcase `pthread_test` freezes when waiting for clear tid futex wakeups. It turns out to be that we forget to call .await in `futex_exit()` so `do_futex_exit()` is never called. Fix by appending the missing `.await`. Fixes: b6d54d6 ("mm, proc: add an exited thread reaper") Signed-off-by: greatbridf <greatbridf@icloud.com>
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.
Summary
Testcase
/mnt/pthread_testhangs after the threads are joined (issue #61): the process reaches the end of the test but never exits, freezing forever in the clear-tid futex wait.Root cause:
futex_exit()insrc/kernel/task/futex.rscalleddo_futex_exit(thread)without awaiting the returned future:Because
let _ = <future>merely drops the future,do_futex_exit()was never executed at all. As a result the thread was never detached from its futex state and the clear-tid futex wakeups were never performed, so the joiner kept waiting forever.Fix
One-line fix: actually await the future so
do_futex_exit()runs.pub async fn futex_exit(thread: &Thread) { // We don't care about any error happened inside. // If they've set up a wrong pointer, good luck to them... - let _ = do_futex_exit(thread); + let _ = do_futex_exit(thread).await; }Fixes a regression from b6d54d6 ("mm, proc: add an exited thread reaper").
Verification
Reproduced and verified with
make run MODE=release, running/mnt/pthread_testin the guest:pthread_join.Final counter value: 20000and the process exits normally.Fixes #61