Repository navigation
fix6: state-vis slice — job-state observation timing, mapfile -C callback, BASH_SOURCE (#1586, #1587, #1604, #1607, #1612) - #1705
Merged
Conversation
…fired per record during the read (rubash#1586) GNU mapfile.def run_callback appends ` <index> <quoted line>` to the callback string and evals the whole thing; rubash whitespace-split the string into a command + fixed words, shifting every argument. The callback form now builds "<cb> <idx> '<line>'" with the line sh-single-quoted and runs it through execute_eval_source (its visibility widened to pub(in crate::executor) for this call). Firing also moves into the read itself: execute_mapfile_with_callback pulls records incrementally (byte-domain puller over real fds/files, pre-split values for materialized sources) and fires the callback after binding the previous record and before binding the current one, matching GNU's array state during the callback. Regression: tests/issue1586_mapfile_callback_eval_regressions.rs (6 tests, GNU bash 5.3.20 oracle; the streaming case drives a coproc fd — a builtin pipeline stage is fed from the parked FUNCTION_STDIN mirror on this tree, so a pipe shape cannot observe interleaving). Co-Authored-By: Muse Spark <[email protected]>
…n file, not the caller (rubash#1587) Entering a function call framed BASH_SOURCE[0] from the caller's source stream, so a function defined in lib.sh but invoked from main.sh saw main.sh. The call frame now takes element 0 from function_definition_locations (the file the definition was read from), falling back to the caller source only when no definition site was recorded. Regression: tests/issue1587_bash_source_definition_regressions.rs (2 tests: file invocation and -c invocation). Co-Authored-By: Muse Spark <[email protected]>
…e command early (rubash#1607) Deferred stop/continue marks from the shell's own kill were applied by reader-command count (seq + 1 < now), so `kill -STOP %1`, one fast builtin, then `jobs` already showed Stopped; GNU still shows Running until a notification point (its waitchld runs when the shell blocks in wait_for, or at the post-command notify cadence). Marks now carry their send instant and publish when the refresh is a real observation event — a wait/fg observed refresh, the shell having blocked on a foreground process since the last refresh, or job control live on a terminal — or, failing that, once the mark is a full reader command old AND ~5ms of wall time has passed (GNU's SIGCHLD-delivery latency across a busy builtin stretch). The state_observe predicate is computed once in the jobs refresh and feeds apply_deferred_state_marks. This commit also widens stdin_source_is_terminal to pub(in crate::executor): the predicate calls it from job_builtins.rs. That widening is rubash#1612's enabling change — its monitor+terminal arm is #1612's publication mechanism, and the refresh face cannot be split further; #1612's own commit carries its regression test. Regression: tests/issue1607_stopped_observation_lag_regressions.rs (3 tests: fast-builtin lag, same-line lag, publish after a foreground wait with promotion to current job). Co-Authored-By: Muse Spark <[email protected]>
…rubash#1612) Mirror of rubash#1607: with job control live on a terminal, GNU publishes a stop at the first notification point after the signal, but rubash's command-count lag never published at all in the pty cadence, so `jobs` kept showing a stopped job as Running forever. The fix itself (the refresh's state_observe predicate and its monitor+terminal arm, plus the stdin_source_is_terminal widening it calls) landed in the previous commit — the jobs-refresh face is shared with #1607 and cannot be split further. This commit carries the regression test and the verification record. Regression: tests/issue1612_pty_stopped_observation_regressions.rs (1 test, driven through a util-linux `script -qec` pty carrier; manual pty run byte-identical to GNU bash 5.3.20: "[1]+ Stopped sleep 30"). Co-Authored-By: Muse Spark <[email protected]>
…ated cannot leak past `wait $p 2>/dev/null` (rubash#1604) GNU learns a death asynchronously and the following wait claims the job, suppressing its notice (jobs.c wait_for marks it notified). Rubash's boundary sweep could reap the zombie first and queue the notice outside the wait, printing it to raw stderr (~1/6 of runs). The kill builtin now records each fatally-signalled pid (JobTable::note_fatal_signal); when the boundary sweep reaps such a job it stashes the completion instead of applying it, and the wait's own observed refresh applies it under the wait's fd 2, where the notice drains through the redirect. The mark's window spans the sending reader command AND the following one: the incidental reap lands at the following command's pre-execution sweep (ast_exec runs the refresh before a command executes, not after the previous one), which is where the leak actually escaped — a one-command window still leaked 10/24 seed runs under load; the two-command window leaks 0/24 against the baseline's 3/24. Regression: tests/issue1604_killed_notice_wait_leak_regressions.rs (1 test, 6 seed runs per invocation, each demanding exactly one Killed notice — the second job's). Co-Authored-By: Muse Spark <[email protected]>
Member
Author
|
Integration gates on this tree (base master 2157a3a + the five cherry-picks, no conflicts):
Merging on green. |
This was referenced Oct 26, 2026
Merged
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.
State-visibility slice (wave 6, fix6/state-vis cluster): five fixes around job-state observation timing,
mapfile -Ccallback evaluation, andBASH_SOURCEin functions. Cluster verification on the f6b5a3f baseline: targeted 13/13, lib 771 pass / 1 fail / 1 ignored (failure set = {ownership_unary_operators_check_existing_file}, same as baseline), fmt clean. Integrated onto current master by cherry-pick (no conflicts).Fixes #1586
Fixes #1587
Fixes #1604
Fixes #1607
Fixes #1612
Per issue
mapfile -Ccallback was word-split (callback string broken into command + fixed words, arguments shifted) and only fired after the whole input was slurped, so callbacks could not see the array bound up to the previous record. The callback string is now evaluated as a command string (GNUmapfile.defrun_callbackshape) and fired per record during the read via an incremental driver; materialized sources (heredoc/text/procsub endpoints) are pre-split but still fire per record.BASH_SOURCE[0]inside a function reported the caller's source stream; it now reports the definition file recorded infunction_definition_locations, falling back to the caller only when no record exists.Instant; publication requires a real observation event (wait/fg observation refresh, foreground block since last refresh, or monitor+terminal present), or a mark that is a full reader command old and aged ≥5 ms. Known sensitivity, recorded in the cluster report: the 5 ms wall-clock aging gate can be crossed under heavy preemption (~1/8 at load 13–16); quiet-machine and final cluster runs are 3/3 green.state_observepredicate (mechanism landed with [bug] jobs refreshes stopped state one command early when a builtin intervenes after kill -STOP (residual of #1494) #1607) plus a pty regression test (script -qeccarrier); manual pty output byte-identical to GNU 5.3.20.Killednotice for a job terminated by the shell's ownkillleaked pastwait $p 2>/dev/null: a command-boundary opportunistic reap applied the completion beforewaitcould claim it, so the notice went to the bare stderr.killnow accounts each fatally-signalled pid; boundary reaps of accounted pids are stashed unapplied untilwait's own observation refresh applies them underwait's fd 2 (GNUjobs.cwait_forclaiming semantics).#1604 window correction (found during cluster final verification)
The original cluster fix kept the fatal-signal mark alive for one reader command, but the opportunistic reap actually lands in the pre-execution sweep of the next command (the ast_exec refresh runs before a command executes, not after the previous one, and before that command's redirections are installed) — by then the mark had already been retired. Measured on the baseline tree under load 13–16: baseline 3/24 leaks, one-command window 10/24, widened window (send command + the one immediately after; one-line change in each of the
note_reader_commandretain andtake_fresh_fatalpredicates insrc/jobs/table.rs) 0/24. Adjacent job-notice nets re-run after the widening: 14 pass / 0 fail.Integration gates (this tree): targeted tests for all five issues, #1604 leak count ≥20 runs, lib full suite failure-set identity vs baseline, diffcorpus 306 failure set ⊆ {ms10}, rustfmt on changed files. Results are posted as a PR comment when the gates finish.