Marshal sched_getaffinity masks across process memory - #884
Closed
brandonpayton wants to merge 1 commit into
Closed
Conversation
This was referenced Jul 11, 2026
brandonpayton
force-pushed
the
fix/sched-getaffinity-marshalling
branch
from
July 11, 2026 21:30
8fa793e to
02e63bc
Compare
Member
Author
|
CI note: the failed Vitest job was rerun and reproduced only the same setup-timing assertion at host/test/teardown-reclaim.test.ts:71; every other suite remains green. The race is root-caused and fixed independently in #889, whose complete kernel/fork/Vitest/browser/libc/POSIX/Sortix gate is green. The unchanged pre-#889 merge base cannot make that test deterministic, so further reruns would not add evidence; merge or rebase after #889 is the correct path. |
This was referenced Jul 12, 2026
brandonpayton
added a commit
that referenced
this pull request
Jul 13, 2026
Implement sched_getaffinity as a Linux-compatible one-CPU surface with fixed four-byte raw masks, exact live-task lookup, Linux errno ordering, and unsigned-u32 length normalization across wasm32 and wasm64 callers. Route the output through the generated host ABI for both Node and browser workers. Cover raw versus musl return behavior, large and precision-sensitive lengths, missing and dead tasks, live pthread TIDs, and browser execution. Advance ABI 37 to 38 and regenerate the snapshot, C header, and TypeScript bindings atomically. Source-PR: #884
Member
Author
|
Merged PR #907 supersedes this work through the strengthened affinity marshalling implementation now on main at |
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.
Purpose
Make
sched_getaffinity(2)return its CPU mask through the normal guest/host/kernel memory contract instead of dereferencing a guest address in kernel memory.This surfaced while validating the Kandelo Homebrew
xzformula: liblzma probes the available CPU count before using its multithreaded encoder.Root Cause
Syscall 238 was implemented in the Rust kernel, but absent from the shared host syscall-argument descriptors. The host therefore forwarded the process-memory pointer unchanged. The kernel interpreted that address in its own Wasm memory when constructing the output slice, trapped out of bounds, and the host converted the trap to
EIO.The change:
SchedGetaffinityin the shared syscall inventory;ABI
The branch is rebased unchanged onto ABI 18 at
02e63bc46; its patch ID remainsee5f0f65460ab68429029f020def965b93fc4dac.scripts/check-abi-version.shclassifies the two snapshot entries as additive-compatible:Existing ABI entries are unchanged, so
ABI_VERSIONremains 18. The ABI snapshot and generated TypeScript bindings are committed in sync.Validation
Exact ABI 18 rebase validation through
scripts/dev-shell.sh:bash scripts/check-abi-version.sh: passed; snapshot, libc header, and TypeScript bindings are in sync;sched_getaffinity_marshals_the_requested_cpuset: passed;git diff --check: passed;The pre-rebase branch also passed kernel/shared tests, generated ABI and focused host tests, Node and Chromium runtime fixtures, POSIX, libc-test, and Sortix validation as recorded in the earlier PR run. CI is rebuilding the rebased branch against ABI 18.
cargo fmtis not available in the repository dev shell; the Rust changes retain the surrounding formatter style.This main-repository PR is intentionally left for Brandon's review and must not be auto-merged.