Repository navigation
test(servers): discard interrupted-child profiles and let exiting servers finish theirs (#4978) - #8395
Conversation
… children (#4978) The interrupted-run controls terminate an instrumented ripr child at 0-40ms, which can land while it writes its profile at exit. The truncated .profraw then fails llvm-profdata merge for the whole coverage run. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BhjduQtMUKUnheruL7mphH
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 49 minutes. View limit details
Comment |
|
In-session proof on head 3de9b9e:
Adding Generated by Claude Code |
…ned kill (#4978) Drop for the stdio MCP/LSP test sessions now closes stdin and waits up to 2s for the server to exit before killing it, so an instrumented server that is already exiting cannot be cut off mid profile write. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BhjduQtMUKUnheruL7mphH
There was a problem hiding this comment.
Decision
- Needs reviewer attention before upstream: findings remain.
Confirmed findings
- chaos_interrupted_runs local pass count drops to 8/9 due to env-dependent doctor test; CI non-root run is the actual gate. PR body acknowledges this.
- crates/ripr/tests/chaos_interrupted_runs.rs:22 — The doc comment claims this prevents #4978 regression in these two tests, but the PR body and author comment explicitly state #4978 remains open. Consider tightening the wording to 'avoids these two tests producing truncated .profraw' so the doc matches the residual-risk claim.
Verification questions
- Confirm termination races remain: thread::sleep(Duration::from_micros(delay_micros)) then TerminateProcess does not guarantee the child opened/closed its profile file before kill; red/green is empirical, not deterministic.
- Confirm doctor permission test fails as root on host both before and after — environmental, not regression. Verify CI runs as non-root so test stays green.
- Confirm the intended red/green check (test observes a truncated profraw pre-patch, none post-patch) is performed manually outside the test binary; no in-test assertion guards against regression if LLVM_PROFILE_FILE scoping is accidentally widened or removed.
Refuted
- Adding .env(LLVM_PROFILE_FILE,/dev/null) makes the assertions tautological because the child can no longer emit any coverage, so 'interrupted profile write' is no longer being exercised.; refuted because: Assertion targets (cache file present after kill; previous-artifact invariant) are independent of the coverage profile. The interrupted-child behavior under test (cache/artifact outcomes when killed mid-run) is still exercised; only the side-effect of writing a profile is suppressed.
- The new env(LLVM_PROFILE_FILE, /dev/null) on the two terminated children might leak and disable coverage for the parent test binary, silently suppressing real failures.; refuted because: The scope is the per-spawn Command builder only; parent process and the test binary itself inherit env from cargo test, not from the spawned child's .env() override. Doc comment justifies the suppression as narrowing to the deliberately terminated children, mirroring accepted #5170. Read of Command::env semantics confirms child-only.
- Setting LLVM_PROFILE_FILE=/dev/null on the child is racy or might be inherited by parent test binary or other spawned processes; refuted because: env() on a single Command::spawn scopes to that child only; Command does not propagate to parent. Other tests in the same binary use their own Command builders and are unaffected.
Parked follow-ups
- PR explicitly disclaims fixing #4978: parallel profile truncation paths (LSP/MCP Drop kills, hostile_repos deadline, fixture_git) are residual and parked as follow-ups.
- hostile_repos.rs:114 and common/fixture_git.rs:358 also kill instrumented children at deadline/Drop — unproven non-producers per author's own admission.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BhjduQtMUKUnheruL7mphH
|
Local proof on head fdc4945:
Labeling merge-ready. Generated by Claude Code |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Generated by Claude Code |
There was a problem hiding this comment.
Decision
- Needs reviewer attention before upstream: findings remain.
Confirmed findings
- #4978 remains open by author admission; patch fixes only two of at least three known kill sites (chaos only). Hostile_repos.rs:114 and common/fixture_git.rs:358 still kill instrumented children without grace or /dev/null. Until main rust-coverage is green over several runs, the patch is a partial mitigation and reviewers should not infer #4978 is closed.
Verification questions
- Confirm no test in this diff performs a red/green oracle: nothing asserts the child would have produced a truncated .profraw pre-patch or that it doesn't post-patch. The two env-redirect sites are silent; the red→green proof lives in the PR author's manual
llvm-profdata showrun (2/11→0/6). - Confirm no in-test assertion guards against regression: the proof of 'no truncated profraw' is the author's manual llvm-profdata show loop, not a test that would fail if the env-var were dropped. The chaos tests still pass without the LLVM_PROFILE_FILE override; they would also pass with it removed.
- Confirm drop grace relies on stdin EOF being observed by the server within 2s; an LSP/MCP server that is mid-request and not reading stdin at the moment of drop will not exit on its own, so kill still fires and truncates a profile if it lands inside LLVM profile write.
Refuted
- The new tests (or modified existing tests) should fail on unpatched main and pass on this PR's head, supplying the red/green oracle the review rubric asks for.; refuted because: Per the seeded author comment and PR body, this PR adds zero new oracle assertions. The 'before' state was checked by manual
llvm-profdata show, not by a test that can be re-run in CI. The red→green transition is empirical, not test-resident. - chaos_interrupted_runs assertions are smoke-only and cannot detect the fix; refuted because: The fix is environmental (prevent the .profraw from being written at all), so in-process assertions on child behavior cannot observe it. The discrimination lives in llvm-profdata merge output, which is a CI-only witness. The PR body, author comment, and review summary acknowledge this; the change is minimal and the env-var is correctly scoped.
Parked follow-ups
- Five Drop impls duplicate an identical 6-line grace block; divergence risk between sites if policy ever tightens (e.g. SIGKILL fallback, retry, panic-safety). Not a correctness blocker; oracle concern is maintenance, not discrimination.
- The duplicate grace-poll snippet across 6 Drop impls invites a shared helper but adds no test value; absent a red/green oracle, helper extraction risks silently shifting behavior. Park for follow-up; not a red/green blocker.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
- cargo-test sensor is scheduled-late with no receipt yet; on a tests-only diff the actual red/green signal lives in cargo test. Without the receipt the gate has no witness that the five Drop changes do not introduce a hang or panic under coverage.
Requested by Steven · project thread
Before: main's
rust-coveragejob fails most runs after all tests pass:llvm-profdata mergerejects one truncatedripr-swarm-<pid>-*.profraw("file header is corrupt", #4978).After: the two interrupted-run controls in
chaos_interrupted_runs.rsgive their deliberately terminatedripr checkchildrenLLVM_PROFILE_FILE=/dev/null, so a child cut off while writing its profile can no longer leave a truncated file. The parent test binary and every other process keep their profiles; same shape as the accepted #5170 scoping.How: those tests terminate an instrumented
riprat 0 to 40 ms, which can land inside the exit-time profile write. Local repro with-C instrument-coverage,%p-%mprofile names andllvm-profdata showper file: before the change 2 truncated profiles in 11 runs of the test binary; after, 0 in 6 runs. The earlier hypothesis (ripr_help_process_contractfixtures) was refuted: they die while idle and write no profile. Not verified: that this is the only producer (LSP/MCP tests also kill servers in Drop), and the hosted all-features coverage run. Closes nothing in #4978; the issue stays open until main coverage is green over several runs.Proof:
cargo xtask precommitexit 0.chaos_interrupted_runsstill passes exceptdoctor_says_when_the_cache_cannot_be_written, which fails as root on this host before and after (permission test).Generated by Claude Code