Repository navigation
WIP: procsub + locale mopup — #1690 compound procsub assignment, #1691 temp-file leak, #1692 setlocale warning - #1793
Merged
Merged
Conversation
…ion (rubash#1690) The raw process-substitution branch of expand_assignment_value_with_raw re-derived the value from the raw RHS and fed it to expand_assignment_value without the cooked value's COMPOUND_ASSIGNMENT_MARKER, so the inner expansion treated a compound RHS as a plain scalar: a=(<(echo one) <(echo two)) stored ONE element whose text was the whole parenthesized string. GNU arrayfunc.c:557 expand_compound_array_assignment splits the body into element words first (parse_string_to_word_list, arrayfunc.c:581) and expands each; compoundness is a property of the assignment, not of the expansion route. Mirror that by carrying the marker onto the materialized text, next to the existing quoted-marker arm. Regression: tests/issue1690_compound_procsub_assignment.rs (script-file matrix, expected output is literal GNU bash 5.3.20 output; fd numbers normalized).
…ubash#1691)
rubash-process-subst-*.tmp carriers leaked in $TMPDIR past shell exit
on two routes (GNU leaks none):
1. Assignment contexts. Both assignment materializers
(materialize_assignment_process_substitutions_from_raw and
materialize_assignment_process_substitutions) discarded the path
returned by write_process_substitution_temp_bytes. The paths now
land in the new Executor field
assignment_input_process_substitution_files and are removed at the
top of finish_assignment_output_process_substitutions_for_command,
before its output-queue early return. That finish runs at every
simple-command end, which is the lifetime GNU gives the
substitution: its fd word is dead by the next command (verified
oracle for scalar and array alike), and in-shell readers keep
working through the in-memory stream registry.
2. External redirect consumers. open_input_redirect's consume branch
(and open_fd_read_endpoint's text/procsub arm) served a registered
stream's remaining bytes by writing a FRESH temp file, opening it
for the child, and dropping the path. Those paths now park in
ShellState::procsub_adhoc_carriers and are removed by
finish_process_substitutions, the per-command finish every consumer
route reaches after its child/read completes. A ShellState clone
starts with an empty list, so a fork child can only drain carriers
it wrote itself.
src/executor/{mod,init,command_substitution}.rs also gain the
Executor fields for the rubash#1692 locale-warning deferral; they are
wired up by the following commit.
Regression: tests/issue1691_procsub_temp_leak.rs — per-case fresh
TMPDIR, asserts the directory is empty after exit AND stdout is the
GNU output, across assignment, redirect-consumer and previously-clean
contexts.
…ts (rubash#1692) GNU binds LANG and every LC_* variable to sv_locale (variables.c:5800 special_vars -> variables.c:6272 sv_locale -> locale.c:185 set_locale_var): a bind performs a real setlocale attempt and a failed one warns 'setlocale: <name>: cannot change locale (<value>)' with a strerror suffix only on the first failing attempt of a (category, name) pair per process. rubash never warned at all: check_setlocale_warning was a deliberate no-op. src/locale.rs now mirrors the C flow for real: attempt_setlocale clears errno, calls libc::setlocale and reports strerror(errno) only when the call left it set (glibc's caching yields the suffix rule); locale_assignment_warning reproduces set_locale_var/set_lang — LC_ALL non-empty attempts once and warns; LC_ALL empty takes the silent reset path; a category is attempted only while LC_ALL is empty, with the get_locale_var precedence value (LC_ALL > own > LANG > "", locale.c:343), so LANG=bad followed by LC_CTYPE= warns about LC_CTYPE carrying LANG's value; LANG never warns. init_locale primes with setlocale(LC_ALL, "") like set_default_locale (locale.c:85), then warns for a bad environment LC_ALL with the argv[0] prefix, no line number and no suffix — startup LANG/LC_* stay silent, as in GNU. Executor wiring: note_locale_assignment fires GNU's watcher at every true bind — the assignment store tail, the tempenv shadow store, declare's two bind paths, export/readonly gated on an actual value operand (a name-only export merely marks the attribute in GNU and must not warn), tempenv teardown restores, function-frame pops, the dispatch merge restore and the for-loop variable bind. A simple command's tempenv is deferred in execute_materialized_command until its class is known: GNU binds tempenv only for builtin/function commands (a disk command's assignments become child-env entries), so deferred binds flush for the binding classes and drop for disk commands. The stale post-hoc stub call in the export builtin is gone (its sync_process_locale stays). No interplay with the rubash#1531 LC_COLLATE watcher or the rubash#1533 C-locale byte-semantics pins: locale readers stay env-driven, and the process locale now actually follows binds the way GNU's does. Regression: tests/issue1692_setlocale_warning.rs — assignment form (suffix on first failure only), category form, silent cases, startup LC_ALL-only warning, tempenv external-silent vs builtin-warns. Expected text is literal GNU bash 5.3.20 output.
…nings attempt_setlocale cleared and re-read errno via libc::__errno_location(), a glibc-only spelling: the libc crate exposes it neither on Darwin (__error) nor on Android's bionic (__errno), so the lib failed to compile on macOS and in the darwin/android cross-target checks (E0425 in the macOS, cross-darwin and cross-android CI jobs on PR #1793). Route both accesses through a cfg-dispatched errno_location() helper instead: glibc/musl keep __errno_location, Darwin and FreeBSD use __error, and Android uses __errno. The clear-before / read-after protocol mirroring GNU locale.c:191 set_locale_var is unchanged, so observable behavior on Linux/glibc is identical (the strerror suffix still appears only on the first failing bind of a locale name): issue1692_setlocale_warning passes 5/5 and the lib suite holds its baseline of 771 passed / 1 failed (ownership_unary_operators_check_existing_file, pre-existing) / 1 ignored. Cross-target compilation itself is adjudicated by CI; this machine has neither a Darwin-capable C toolchain nor an Android NDK for the dependencies' cc-rs build scripts.
Member
Author
|
errno 可移植性修复已推送(0030f2c4) CI 四红中的三红同根,已定性并修复:
|
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.
Mopup cluster (find-hunt r6, double-run verified): three fixes, one commit each, all gates green locally. Opened as draft per the visibility rule; verification/merge goes through the integration pipeline — do not merge directly.
Commits
1918a40eFixes [bug] Compound array assignment with process substitution collapses to one parenthesized element #1690 — compound array assignment with process substitution collapsed to one parenthesized scalar element. The raw-procsub branch ofexpand_assignment_value_with_rawdropped the cooked value'sCOMPOUND_ASSIGNMENT_MARKER; it is now carried onto the materialized text (GNU arrayfunc.c:557expand_compound_array_assignmentsplits the body into element words first, so compoundness is a property of the assignment, not of the expansion route). Pair/mix/triple/>(...)/append/declare -a/local -ashapes verified byte-identical to GNU bash 5.3.20. Note: procsub fd words are dead by the next command in GNU for scalar and array alike, so the test asserts element shape/count, not later readability.1333efaaFixes [bug] Process-substitution temp files leak in TMPDIR for external-command redirects and assignments #1691 —rubash-process-subst-*.tmpcarriers leaked in $TMPDIR past shell exit on two routes: (1) both assignment materializers discarded the temp path — now collected in a new Executor field and drained at the per-command assignment finish; (2)open_input_redirect's consume branch (andopen_fd_read_endpoint's text/procsub arm) wrote a fresh carrier for external children and dropped the path — now parked inShellState::procsub_adhoc_carriersand removed byfinish_process_substitutions; ShellState clones start empty so a fork child only drains its own. Verified by actually diffing $TMPDIR contents after exit: leak matrix (11 cases) + route matrix (10 cases) all zero with GNU-identical stdout. Windows note: if a pipeline child still holds the file open, remove fails silently there (same shape as the existing dispatch-carrier cleanup); Linux unlink-after-open is unaffected.6537b06cFixes [bug] Missing setlocale warning for invalid LC_ALL (startup env and assignment) #1692 — invalidLC_ALL/category assignments (and startup env) now emit GNU's setlocale warning.src/locale.rsmirrorssv_locale(variables.c:6272 → locale.c:185) with reallibc::setlocaleattempts: strerror suffix only on the first failing (category, name) attempt per process, LC_ALL/category/LANG/reset semantics, startup priming + argv[0]-prefixed warning. Executor wiring fires at every true bind (assignment store, tempenv shadow, declare, export/readonly gated on a value operand, tempenv + function-frame restores, for-loop bind); simple-command tempenv defers until the command class is known (GNU binds only for builtin/function). LC_COLLATE: plain (unexported) assignment does not re-collate glob order or [[ < ]] (#1512 follow-up) #1531 LC_COLLATE watcher and matcher: glob ? matches a character instead of one byte in C/POSIX locale (pattern removal over multibyte values) #1533 C-locale byte-semantics pins untouched.Regression tests (expectations per GNU)
tests/issue1690_compound_procsub_assignment.rs— 1 testtests/issue1691_procsub_temp_leak.rs— 3 tests (fresh TMPDIR per case, asserts empty after exit)tests/issue1692_setlocale_warning.rs— 5 testsGates (final tree, purified env, build-slot)
ownership_unary_operators_check_existing_file, same set as masterKnown non-parity (documented in cluster REPORT.md)
Full cluster report:
~/workspace/rubash-fix8/clusters/procsub/REPORT.md(local workspace).