Repository navigation
thread: fix 32-bit legacy sleep fallbacks - #1719
Open
kmehltretter82 wants to merge 2 commits into
Open
kmehltretter82 wants to merge 2 commits into
kmehltretter82 wants to merge 2 commits into
Conversation
On 32-bit Linux, the legacy clock_nanosleep and nanosleep fallbacks return on EINTR before copying the old-timespec remainder. They also read the remainder after success, when the kernel need not initialize it. Convert and copy the old remainder only when the syscall returns EINTR, then return the syscall result.
On 32-bit Linux, the legacy clock_nanosleep fallback omits TIMER_ABSTIME, so the kernel interprets the absolute deadline as a relative duration. Pass TIMER_ABSTIME, matching the time64 and 64-bit paths.
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.
On 32-bit Linux with the linux_raw backend, Rustix falls back to the legacy
sleep syscalls when
clock_nanosleep_time64returnsENOSYS.The relative fallbacks currently return on
EINTRbefore copying theold-timespec remainder and read that remainder after successful calls, when it
is not initialized. The absolute fallback passes flags
0, so the kerneltreats its deadline as a relative duration.
This series copies legacy remainders only on
EINTRand preservesTIMER_ABSTIMEin the absolute fallback.Testing
On a physical ARMv5 SAM9X75 running Linux 6.18, a process-local seccomp filter
returned
ENOSYSonly forclock_nanosleep_time64to exercise the legacypaths. The unpatched absolute call slept for about 50 ms instead of returning
immediately, and both interrupted relative calls returned corrupt remainders.
All three cases passed with this series.
straceconfirmed the transition tothe legacy syscalls.
cargo +stable check --locked --offline --target armv5te-unknown-linux-musleabi --features=all-apis --libcargo +stable check --locked --offline --target i686-unknown-linux-musl --features=all-apis --libcargo +stable fmt --check