fix(daemon): drop listen sockets held by helper children - #1831
ScriptedAlchemy wants to merge 1 commit into
Conversation
Fork duplicates the daemon's listen socket. FD_CLOEXEC drops it at exec, not before, so a helper still between those calls keeps accepting after a pid-only kill. Children now die with that parent, and the test stop signals the process group the harness created for the daemon. Co-authored-by: Zack Jackson <ScriptedAlchemy@users.noreply.github.com>
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ffafc6fcc5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| #[test] | ||
| fn helper_between_fork_and_exec_releases_the_listen_socket_when_its_parent_dies() { |
There was a problem hiding this comment.
Gate the parent-death test to Linux
In the macOS core-storage CI partition, this test is compiled because the containing module is gated only on unix, but arm_helper_parent_death() explicitly returns success without registering a handler on non-Linux targets. The PID-only leader.child.kill() therefore leaves the paused helper holding the socket, so the assertion after the two-second wait fails deterministically on macOS. Restrict this test to Linux or give non-Linux platforms a supported parent-death mechanism.
Useful? React with 👍 / 👎.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Review lane verdict: REJECT as a merge candidate for now. PR_SET_PDEATHSIG armed via pthread_atfork is Linux-only and the macOS CI lane builds the daemon bootstrap; the harness half (group SIGKILL in terminate_and_reap) is landing via #1833 in batch #1848. If the production root-cause half is still wanted, please rebase onto master after #1848 lands, drop the tests/common/mod.rs hunk, and gate the PDEATHSIG path on cfg(target_os = "linux") with a no-op elsewhere. |
|
Closing after a second review with an experiment. The production half cannot fire. The window it targets is already closed. The listen socket is close-on-exec, so any child drops it at The harness half already landed via #1833 in #1848: If the predecessor-socket symptom recurs on a loaded runner, fork inheritance is not the mechanism, and it needs its own investigation. |
Summary
forkandexecno longer keeps the listen socket after the parent is killed: the child asks the kernel to die with that parent.process_group(0)created, instead of only the leader pid.Motivation
Tip
3f71bccb2dbastill only waited for a predecessor socket to stop accepting. That wait treats the symptom.forkduplicates the listen descriptor;FD_CLOEXECdrops it atexec, not before. A pid-onlySIGKILLof the leader leaves that child accepting. Local census: after the leader is killed, connect still succeeds until the process group is signalled.Changes
crates/tracedecay-runtime-core/src/process_tree.rs:arm_helper_parent_death(PR_SET_PDEATHSIG) andsignal_process_group.run_foreground_unixarms parent-death before any helper is forked.Test plan
cargo test -p tracedecay-runtime-core --lib process_tree -- --test-threads=1— 2 passed. The parent-death test fails closed if a pid-only kill leaves the socket up. The group test first shows the socket still accepts after a pid-only kill, then fails that connect after the group signal.cargo clippy -p tracedecay-runtime-core --lib --tests --offline -- -D warnings— exit 0cargo check -p tracedecay --lib— exit 0Checklist
CHANGELOG.mdupdated (process teardown; no command or wire change).envfiles includedSHA:
ffafc6fcc5f83be6531f40823662d1476d37a345