Repository navigation
Resume interrupted futex waits, polls, and selects like Linux - #1761
Merged
Weiteng Chen (CvvT) merged 6 commits intoOct 30, 2026
Merged
Conversation
Like Linux, a signal that runs no handler no longer makes blocking waits fail with EINTR: - A futex wait with a timeout and poll resume through restart_syscall (ERESTART_RESTARTBLOCK) until their original deadline, the futex wait checking its word again and poll reading its fds again. - ppoll, select, and pselect6 write back the time left on every return, including argument errors, and are reissued (ERESTARTNOHAND). An interrupted call that cannot write the time back fails with EINTR. - ppoll, pselect6, and epoll_pwait keep their temporary signal mask until the signals that interrupt them are delivered (saved_sigmask, like Linux's TIF_RESTORE_SIGMASK), so a signal the mask unblocks reaches its handler, whose frame saves the caller's mask. ppoll and epoll_pwait now honor their mask, and a NULL mask is ignored whatever its size, which glibc's pselect(..., NULL) relies on. FutexManager::wait no longer loses a wake that takes the waiter as its wait times out or is interrupted: like Linux, the waiter then reports the wake. Instant gains a required saturating_add, so deadlines are always representable, and absolute deadlines are capped at KTIME_MAX since boot like relative ones. The Linux-userland broker's Instant now reads CLOCK_MONOTONIC as a Duration. The new wait_restart.c runner test, validated natively, checks these behaviors deterministically. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Drop unit tests that the wait_restart.c runner test already covers deterministically, keeping only those that check what it cannot: the lost-wake race, futex resumption, pselect restoring its mask on bad arguments, delivery under the restored mask, and the absolute deadline cap. Restore the shared racing-futex test to its original form, and fold overlapping C test cases together. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Windows recovers faulting user-memory accesses only on threads with LiteBox TLS installed, so tests that intentionally fault must run under run_test_thread. This fixes the Windows CI crash in test_pselect_with_bad_arguments_restores_its_mask and re-enables inaccessible_memory_faults and test_fallible_read on Windows. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
On macOS, run_test_thread installs per-thread TLS using the key created by MacosUserland::new(). Calling init_platform() inside the closure meant the key did not exist yet in a fresh nextest process, aborting with "macOS TLS is not initialized". Initialize the platform first, as other tests do. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🤖 SemverChecks 🤖 Click for details |
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.
Follow-up to #1746, which did this for
nanosleep. Blocking waits no longer fail withEINTRwhen interrupted by a signal that runs no handler, such as an ignoredSIGCHLDqueued while the sender had every signal blocked. Like Linux, they now resume or are reissued transparently.