Repository navigation
WIP: fix BASHPID origin seeding at input-procsub producer and coproc respawns - #2243
Merged
Merged
Conversation
…d coproc respawns Refs #1582 Two fork-shaped respawn sites seeded __RUBASH_SUBSHELL_DEPTH for the child shell but not __RUBASH_BG_BASHPID_BASE, so the child's own $BASHPID read its real pid + 1 (depth offset applied on top of the real pid). GNU: BASHPID is getpid() of the reading shell (variables.c:1511), and a process-substitution producer / coproc body is a forked shell in its own right (subst.c:6362), so its BASHPID must equal its real pid and its children's PPID. Audit of all four respawn sites: the async wrapper and the output-procsub consumer already stamp both carriers; the input-procsub producer (trap_exec.rs) and the coproc shell route (compound_exec.rs) stamped depth only. Both now stamp __RUBASH_BG_BASHPID_BASE with the same value as the depth stamp, mirroring the consumer site's pair. Regression pins (tests/regression.rs, mod issue_1582), all three-way BASHPID == child-PPID == parent-known-pid checks: - issue1582_coproc_bashpid_matches_child_ppid (red on baseline) - issue1582_input_procsub_producer_bashpid_matches_child_ppid (red on baseline) - issue1582_output_procsub_consumer_bashpid_matches_child_ppid (guard for the already-correct site) The flat-layer synthetic BASHPID projection itself is unchanged; its remaining divergences are an adjudicated design surface, not touched here.
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.
Refs #1582
What this fixes
A real bug family distinct from the flat-layer $BASHPID projection
tradeoff: two fork-shaped respawn sites seeded the child's subshell
DEPTH but not its BASHPID ORIGIN base, so a real process's own
$BASHPID read its real pid + 1.
GNU ground truth: BASHPID is getpid() of the reading shell
(variables.c:1511); a process-substitution producer / coproc body is
a forked shell in its own right (subst.c:6362), so its BASHPID must
equal its real pid and the PPID of children it spawns.
Respawn-site audit (all four sites):
Raw-value proof (pre-fix binary): coproc body BASHPID 143606 vs
body-child PPID 143605 (parent-known pid 143605); input-producer
body BASHPID 139055 vs its child PPID 139054. Post-fix: all equal,
matching GNU.
The fix stamps
__RUBASH_BG_BASHPID_BASEwith the same value as the__RUBASH_SUBSHELL_DEPTHstamp at each site, mirroring theoutput-procsub consumer's existing pair.
Regression pins (tests/regression.rs, mod issue_1582)
Three-way checks (body BASHPID == body-spawned child PPID ==
parent-known pid), GNU expectations:
issue1582_coproc_bashpid_matches_child_ppid— red on baselineissue1582_input_procsub_producer_bashpid_matches_child_ppid— red on baselineissue1582_output_procsub_consumer_bashpid_matches_child_ppid— guard pin for the already-correct siteBaseline-red verified by stash comparison (product diff stashed,
pins kept): the two target pins fail, the guard and the three
pre-existing issue1582 contract pins pass. On the fixed tree the
issue1582 module is 6/6 green; neighbor sets (issue_1584,
issue_1951, issue_1952, issue_1646) green except
issue1584_named_coproc_pid_is_the_program, which is red on thestashed baseline in this Linux environment as well (pre-existing,
unrelated to this change).
What this does NOT do
The flat (in-process) subshell BASHPID projection
(pid + depth offset) is unchanged. Its remaining divergences from
GNU are the adjudicated design surface recorded in the cluster
report (projection map + battery): at most two of {BASHPID ==
children's PPID, layers mutually distinct, kill $BASHPID scoped to
own layer} can hold in a no-fork model. The contract pin
issue1582_kill_own_bashpid_stays_scoped_to_the_subshellcontinuesto pass unchanged.