Skip to content

fix(cli): name an Erlang VM crash instead of a bare exit 139 - #1200

Merged
hyperpolymath merged 5 commits into
mainfrom
claude/lucid-turing-q03zj3
Nov 18, 2026
Merged

hyperpolymath merged 5 commits into
mainfrom
claude/lucid-turing-q03zj3

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

What

hypatia-cli.sh no longer execs the escript. It runs it as a child and stays as transparent as exec:

  • stdin, stdout and stderr pass through;
  • TERM, INT and HUP are forwarded;
  • the exit code is unchanged.

When the escript dies by SEGV, BUS, ABRT or ILL, the wrapper prints the signal and the OTP and erts version to stderr only. It gets them from the installation's OTP_VERSION file and erl +V, without evaluating code. It then re-raises the same signal on itself.

Because of the re-raise, callers still get exit 139, and their shell still prints Segmentation fault … hypatia-cli.sh. So the toolchain_segfault triage rule and its fixture keep matching.

Also in this PR:

  • tests/hypatia-cli-signal-test.sh: six cases using fake escripts, wired into escript-soundness.yml right after the consumer-shaped invocation.
  • A ci_failure_triage fixture and row: the wrapper's report alone classifies as toolchain_segfault.

Why

metadatastician/lintel#30 failed with Hypatia scanner execution failed with exit 139, which reads as a scanner fault or as a finding about that repository.

Evidence

  • bash tests/hypatia-cli-signal-test.sh → 6 of 6 PASS, with and without erl on PATH.
  • Negative control: the same test against the old wrapper (main's hypatia-cli.sh) fails the SIGSEGV case only (err= empty).
  • Real crash: the new wrapper in front of the unfixed be98f74 escript, on Lintel d7bdc21's tree, with OTP 28.3.3:
    [hypatia] The Erlang VM running the scanner (beam.smp) was killed by SIGSEGV (exit 139) on OTP 28.3.3 (erts 16.2.2).
    
    The caller's shell still prints Segmentation fault … hypatia-cli.sh, rc is 139, and stdout is empty.
  • mix test test/rules/ci_failure_triage_test.exs → 200 tests, 0 failures (OTP 27.3.4.19, Elixir 1.19.4). mix format --check-formatted passes on the changed test file.
  • shellcheck -S warning passes on hypatia-cli.sh and the new test.
  • A self-scan with the 6693f9a escript reports 0 findings on the changed shell files. An earlier draft that used erl -eval was flagged eval_in_shell and has been rewritten.

For #1062's notes. A stress run over 44 inputs (Lintel trees plus 40 random subsets of its workflows) used escripts built natively on each runtime:

Revision OTP 27.3.4.19 OTP 28.3.3 OTP 28.5.0.8
be98f74 (unfixed) 3/44 crash 5/44 crash 3/44 crash
6693f9a (fixed) 0/44 0/44 0/44

So OTP 27 is not immune without the #1062 compile option. The OTP 27.3.4.19 pin (ruling R2) protects only together with a revision that carries the fix.

Not done

  • CI on this branch has not run yet. It is the check for escript-soundness.yml.
  • No erlang/otp report has been filed. The upstream compiler bug is still open (see Stop the OTP 28 segfault in scans and the RSR oracle (PinSites miscompile) #1062, "Not in this PR").
  • No change to ci_failure_triage's reason text. It still says OTP 27 is unaffected, which the table above contradicts. That's the owner's wording to change.

Generated by Claude Code

hypatia-cli.sh exec'd the escript, so when the BEAM crashed (the PinSites
miscompile, #1062) callers saw only "exit 139" or "Hypatia scanner
execution failed with exit 139". Downstream, that reads as a scanner fault
or as a finding about the scanned repository. Seen on metadatastician/lintel#30,
which still pinned the pre-#1062 revision be98f74.

The wrapper now runs the escript as a child and stays as transparent as
exec: stdin, stdout and stderr pass through, TERM/INT/HUP are forwarded,
and the exit code is unchanged. On SEGV/BUS/ABRT/ILL it prints, to stderr
only, the signal and the OTP and erts version (read from OTP_VERSION and
`erl +V`, no code evaluation). It then re-raises the child's signal on
itself, so the caller's shell still reports "Segmentation fault …
hypatia-cli.sh" and the toolchain_segfault triage rule keeps matching.

Tests:
- tests/hypatia-cli-signal-test.sh (six cases with fake escripts), wired
  into escript-soundness.yml next to the consumer-shaped invocation. It
  passes, and against the old wrapper it fails the SIGSEGV case.
- ci_failure_triage: the wrapper's report alone classifies as
  toolchain_segfault (new fixture).

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4QvDiFtqASJYm1U8JRY6P
TERM, INT, HUP and other signals end a run on purpose and get no crash
report; the default arm now says so instead of falling through.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4QvDiFtqASJYm1U8JRY6P

Copy link
Copy Markdown
Owner Author

Rust License & Ban Check (Security): not caused by this PR.

cargo-deny fails on advisories with two RustSec entries against Cargo.lock, a file this PR doesn't touch (it changes one shell script, one workflow step, one test row and one fixture):

  • RUSTSEC-2026-0543: chrono is unmaintained.
  • RUSTSEC-2026-0544: heap overflow in libz-sys 1.1.31 (via git2).

The same job passed on this PR's base, main at 29a9e4a (run 43997207467, 01:39 UTC). These advisories were evidently added to the RustSec database between that run and this one. The fix is #1201 (libz-sys 1.1.33, chrono → jiff); I'm not porting it here.

Sonar shell:S131 (a case with no default branch) is fixed in 58b5cc7. The fix adds an explicit default arm. Signals other than SEGV/BUS/ABRT/ILL end a run on purpose, so they get no crash report. tests/hypatia-cli-signal-test.sh (6 of 6) and shellcheck pass.


Generated by Claude Code

@hyperpolymath
hyperpolymath marked this pull request as ready for review November 17, 2026 17:51
@hyperpolymath
hyperpolymath enabled auto-merge (squash) November 18, 2026 18:51
Repository owner deleted a comment from coderabbitai Bot Nov 18, 2026
@sonarqubecloud

Copy link
Copy Markdown

@hyperpolymath
hyperpolymath merged commit 53ec5b2 into main Nov 18, 2026
83 checks passed
@hyperpolymath
hyperpolymath deleted the claude/lucid-turing-q03zj3 branch November 18, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants