← Back to Pull requests

bash: disable CoreFoundation in bundled gettext on darwin #565511

Open
unknown opened this pull request with 497 lines diff across 6 files
View on GitHub
unknown unknown commented on Sep 21, 2026 11:38 UTC
Author

<!--
^ Please summarise the changes you have done and explain why they are necessary here ^

For package updates please link to a changelog or describe changes, this helps your fellow maintainers discover breaking updates.
For new packages please briefly describe the package or provide a link to its homepage.
-->

On Darwin, bash links CoreFoundation via the bundled gettext, whose
libintl_setlocale calls CFLocaleCopyPreferredLanguages. CoreFoundation is
not fork-safe, so a VAR=value cmd temporary assignment evaluated in a
forked-but-not-exec'd subshell re-enters setlocale() on teardown and faults
inside CFPreferences:

libsystem_trace _os_log_preferences_refresh <- SIGSEGV
CoreFoundation _CFPreferencesCopyAppValueWithContainerAndConfiguration
CoreFoundation CFLocaleCopyPreferredLanguages
bash libintl_setlocale
bash reset_locale_vars
bash sv_locale
bash dispose_temporary_env

stdenv's isELF/isMachO/isScript do exactly that (LANG=C read ..., added
in ab4295ea0fac to fix #431934), and fixup hooks call them from find | while
loops — so Darwin builds segfault at random. Seen on macOS 26 (26A428) in
wrapQtAppsHook.

Reproducer, no Nix required:

LOOP='find /usr/bin -maxdepth 1 -type f -print0 | head -c 4000 | while IFS= read -r -d "" f; do LANG=C read -r -n 4 -u 3 m 3<"$f" 2>/dev/null; done'
for i in $(seq 1 60); do env -i HOME=/homeless-shelter PATH=/usr/bin:/bin bash -c "$LOOP"; done 2>&1 | grep -c "Segmentation fault"

bash-5.3p15 from master: 15/60 crashes
with this patch: 0/60

--disable-nls drops bash's only CoreFoundation imports
(CFLocaleCopyPreferredLanguages, CFPreferencesCopyAppValue, CFArray,
CFString
); otool -L confirms the framework is gone. musl already passes
this flag in the same expression. No test impact: run-intl is already in
disabled_checks, and the suite is broken on Darwin.

This is arguably an Apple bug — CoreFoundation should abort post-fork with a
diagnostic rather than segfault — but there is no safe way to call CF from a
forked subshell, so bash should not be linking it.

Things done

<!-- Please check what applies. Note that these are not hard requirements but merely serve as information for reviewers. -->

  • Built on platform:

  • - [x] x86_64-linux
    - [ ] aarch64-linux
    - [x] aarch64-darwin
  • Tested, as applicable:

  • - [ ] [NixOS tests] in [nixos/tests].
    - [ ] [Package tests] at passthru.tests.
    - [ ] Tests in [lib/tests] or [pkgs/test] for functions and "core" functionality.
  • Ran nixpkgs-review on this PR. See [nixpkgs-review usage].

  • Tested basic functionality of all binary files, usually in ./result/bin/.

  • Nixpkgs Release Notes

  • - [ ] Package update: when the change is major or breaking.
  • NixOS Release Notes

  • - [ ] Module addition: when adding a new NixOS module.
    - [ ] Module update: when the change is significant.
  • Fits [CONTRIBUTING.md], [pkgs/README.md], [maintainers/README.md] and other READMEs.

  • Follows the [automation/AI policy].
  • [NixOS tests]: https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests
    [Package tests]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#package-tests
    [nixpkgs-review usage]: https://github.com/Mic92/nixpkgs-review#usage

    [CONTRIBUTING.md]: https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md
    [automation/AI policy]: https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#automationai-policy
    [lib/tests]: https://github.com/NixOS/nixpkgs/blob/master/lib/tests
    [maintainers/README.md]: https://github.com/NixOS/nixpkgs/blob/master/maintainers/README.md
    [nixos/tests]: https://github.com/NixOS/nixpkgs/blob/master/nixos/tests
    [pkgs/README.md]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md
    [pkgs/test]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/test

    Diff: 497 lines (+372 / -125) across 6 files Reviewer: mikatammi Review duration: 101393m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.54) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.54 · 497 lines diff across 6 files
    0.54
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.372
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #565511"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 54.5% (MEDIUM) · Higher = larger blast radius
    54.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 30.1% · Safe to merge
    30.1%
    Repository