Repository navigation
Conversation
FreeBSD sets rk_fpid to -1 when PROC_REAP_KILL has no failed target. Pid::from_raw debug-asserts nonnegative input, so a successful reaper_kill panicked in debug builds and produced a bogus negative Pid in release builds. Map nonpositive sentinels to None; positive failed pids and syscall errors are unaffected. The regression test runs in a re-executed test binary so that the reaper domain contains only its own child, and asserts both the killed count and first_failed == None. Fixes bytecodealliance#1763.
xz-dev
force-pushed
the
fix-reaper-kill-no-failure-sentinel
branch
from
December 4, 2026 05:40
62482fc to
f3e2d2a
Compare
Author
|
Local verification on a real FreeBSD 14.3-RELEASE x86_64 guest (quickemu/QEMU, root): Red — test against unpatched The exact failure signature from the downstream report — the kernel signals the child successfully, writes -1 to Green — same test against this PR: The FreeBSD 14.4/15.0 vmactions rows are green as well. |
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.
Fixes #1763.
Problem
FreeBSD's
procctl(PROC_REAP_KILL, …)setsrk_fpidto -1 when no process failed to be signalled (man page: "If no such process exists, therk_fpidfield is set to -1").reaper_killpassed that value straight toPid::from_raw, which debug-assertsraw >= 0— so a fully successful signal operation panicked in debug builds, and producedSome(Pid(-1))instead ofNonein release builds.Observed downstream in procward CI on a FreeBSD 14.3 x86_64 guest (rustix 1.1.6), in a success path with exactly one signalled child and no failures:
rustix/src/pid.rs:44: assertion failed: raw >= 0reaper_kill: https://github.com/xz-dev/procward/actions/runs/40536071916Fix
Map nonpositive sentinel values to
Nonebefore thePidconversion. Positive failed pids and syscall errors keep their existing handling.> 0(rather than!= -1) stays correct for any nonpositive sentinel and matches the man page contract that only an actual failed pid is positive.Same class of conversion bug as #1710.
Test
tests/process/procctl.rs::test_reaper_kill_no_failed_pidreproduces the exact failure: acquire reaper status, spawn one child,reaper_killwithSignal::TERM, assertkilled == 1andfirst_failed == None. Unpatched, this panics inPid::from_rawin debug builds and fails the assertion in release builds.Because a flagless
reaper_killsignals the reaper's whole domain, the test re-executes the test binary so the domain contains only its own child — running it in-process would TERM sibling tests' children. The outer invocation asserts on the inner output because libtest exits successfully even when a filter matches zero tests.The test runs in the existing FreeBSD 14.4/15.0 vmactions CI jobs.
Verification
cargo check --workspace --release --target=x86_64-unknown-freebsd --features=all-apis --all-targetspasses (same command as CI).cargo fmt --checkclean.