Skip to content

fix/futex: forget to .await in futex_exit - #63

Open
greatbridf wants to merge 1 commit into
refactor/mm/pte-mapfrom
fix/pthread-test
Open

greatbridf wants to merge 1 commit into
refactor/mm/pte-mapfrom
fix/pthread-test

Conversation

@greatbridf

Copy link
Copy Markdown
Owner

Summary

Testcase /mnt/pthread_test hangs 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() in src/kernel/task/futex.rs called do_futex_exit(thread) without awaiting the returned future:

let _ = do_futex_exit(thread);

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_test in the guest:

  • Before: the test hangs forever after pthread_join.
  • After: the test prints Final counter value: 20000 and the process exits normally.

Fixes #61

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant