diff --git a/src/syscall/futex.rs b/src/syscall/futex.rs index fdfc8cda66..65216532e6 100644 --- a/src/syscall/futex.rs +++ b/src/syscall/futex.rs @@ -201,15 +201,22 @@ pub fn futex( i += 1; continue; } - let mut context = futex.context_lock.write(token.token()); - if let Some(index) = futex.waitv_index { - if context.futex_wake_index.is_none() { - context.futex_wake_index = Some(index); + let should_wake = { + let mut context = futex.context_lock.write(token.token()); + if let Some(index) = futex.waitv_index { + if context.futex_wake_index.is_none() { + context.futex_wake_index = Some(index); + } } + context.unblock(); + true + }; + if should_wake { + futexes.swap_remove(i); + woken += 1; + } else { + i += 1; } - context.unblock(); - futexes.swap_remove(i); - woken += 1; } futexes.is_empty() diff --git a/src/syscall/process.rs b/src/syscall/process.rs index 76b5bbbb1f..bdf2c0eb85 100644 --- a/src/syscall/process.rs +++ b/src/syscall/process.rs @@ -332,6 +332,7 @@ pub unsafe fn usermode_bootstrap(bootstrap: &Bootstrap, token: &mut CleanLockTok flags, mapper, flusher, + false, // private mapping for bootstrap stack )?) }, );