Skip to content

Stop the OTP 28 segfault in scans and the RSR oracle (PinSites miscompile) - #1062

Merged
hyperpolymath merged 5 commits into
mainfrom
claude/otp283-pin-sites-segfault
Nov 13, 2026
Merged

hyperpolymath merged 5 commits into
mainfrom
claude/otp283-pin-sites-segfault

Conversation

@hyperpolymath

@hyperpolymath hyperpolymath commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

Callers on OTP 28 lose the Hypatia scan and the RSR oracle to a segmentation fault (exit 139). Reported on bactrian e0b9b65 and quintessence 02fec30 (scan, OTP 28.3), zig-dnssec fa8d500 (mix hypatia.rsr_score, OTP 28.3) and rsr-template-repo af8665c (mix hypatia.rsr_score, OTP 28.5.0.8).

Cause. OTP 28 miscompiles Hypatia.Rules.PinSites.walk/4 (seen on 28.3 and 28.5.0.8; OTP 27 is fine). Its seen <> <<c>> accumulator gets an in-place append (private_append) while seen is still referenced. The VM then crashes in garbage collection (sweep_off_heap in erl_gc.c, called from beam_jit_bs_init_bits). The OTP 28.4 fix for OTP-19951 is in the same pass but does not cover this case: 28.5.0.8 still crashes. Which input crashes depends on memory layout.

Fix. @compile :no_ssa_opt_destructive_update on PinSites only, with a comment that says when to remove it. The cost is one copy per appended byte on one YAML line.

Evidence (local, OTP 27.3.4.19, 28.3 and 28.5.0.8; Elixir 1.19.4 as the failing jobs pin)

mix hypatia.rsr_score <zig-dnssec fa8d500> --ssot rsr-criteria-v2.a2ml:

Build Result
OTP 28.3, main 6/6 segfault, exit 139
OTP 28.3, whole app compiled with no_ssa_opt_destructive_update 6/6 pass
OTP 28.3, only Hypatia's modules compiled with it (deps unchanged) 6/6 pass
OTP 28.5.0.8, main 6/6 pass
OTP 28.3, this PR 10/10 pass

mix hypatia.rsr_score <rsr-template-repo af8665c> (the input of run 43139798509):

Build Result
OTP 28.5.0.8, main 4/4 segfault, exit 139
OTP 28.5.0.8, this PR 4/4 pass
OTP 28.3, main 4/4 pass
OTP 27.3.4.19, main 4/4 pass
  • A bisection over Hypatia's 183 compiled modules (good and bad .beam sets swapped by halves) isolated Elixir.Hypatia.Rules.PinSites.beam; that file alone from the bad set reproduces the crash.
  • The core dump backtrace: sweep_off_heap ← do_minor ← garbage_collect ← beam_jit_bs_init_bits.
  • The scan crash (exit 139 on the escript) did not reproduce on this machine, even unfixed. The crash depends on memory layout. The default scan calls PinSites on every workflow through WorkflowAudit, so it runs the same miscompiled code; this PR covers it, but the scan side is verified by the oracle path, not by its own reproduction.
  • With this PR on OTP 28.3, the escript scan of bactrian, quintessence and zig-dnssec exits 0.

Not in this PR

Moving to OTP 28.5 does not avoid the bug. rsr-template-repo main now pins OTP 27.3.4.19, which is not affected; 28 estate repos still pin 28.3 in stale workflow copies. The estate's reusable workflow (standards hypatia-scan-reusable.yml) and Hypatia's rsr-oracle.yml default to 28.5.0.8, which is affected. Those are changes outside this PR. The bug should also be reported upstream to erlang/otp with these reproductions.

Test plan

  • test/pin_sites_compile_guard_test.exs: the compile option is recorded in PinSites.module_info(:compile). Fails when the attribute is removed.
  • Full Elixir suite (OTP 27.3.4.19, Elixir 1.17.3): 2785 tests, 0 failures, 246 excluded.
  • mix compile --warnings-as-errors clean; changed files formatted.

https://claude.ai/code/session_0136P7Zo6VBPrBWYUmDJZR1H


Generated by Claude Code

OTP 28.0-28.3 miscompile PinSites.walk/4 (compiler bug OTP-19951, fixed
in OTP 28.4 / compiler 9.0.5). Its `seen <> <<c>>` accumulator gets an
in-place append (private_append) while `seen` is still referenced, and
the VM segfaults in garbage collection (sweep_off_heap, exit 139).
Callers pinned to OTP 28.3 lost the Hypatia scan and the RSR oracle.

Reproduced on zig-dnssec fa8d500 with OTP 28.3 + Elixir 1.19.4:
`mix hypatia.rsr_score` crashed 6/6. Bisecting the compiled modules
isolated PinSites alone. With the destructive-update pass turned off
for this module only, it passes 10/10; OTP 28.5.0.8 passes unchanged.

A test checks that the compile option stays in place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0136P7Zo6VBPrBWYUmDJZR1H
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 4 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: a0184ddd-40be-4d4a-a9ed-4a9039996f5b
Commits

Reviewing files that changed from the base of the PR and between 4815dea and 171ec66.

Files selected for processing: 2

  • lib/rules/pin_sites.ex
  • test/pin_sites_compile_guard_test.exs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Copy link
Copy Markdown
Owner Author

Build Test Images / Integration Status: not caused by this PR.

This PR changes one Elixir module and adds one Elixir test. The image build fails while compiling the Rust CLI, in files this PR does not touch:

  • cli/src/main.rs:282: env!("TARGET") is not defined. deploy/Containerfile never copies cli/build.rs into the image.
  • cli/src/app_state.rs:58: try_update is unstable on the pinned rust:1.94-slim-bookworm image.

The same failure is on every recent PR (see the comment on #1057). Integration Status only summarises the integration jobs, so it fails with it. The fix belongs in a separate change to deploy/Containerfile.


Generated by Claude Code

rsr-template-repo af8665c crashes `mix hypatia.rsr_score` on OTP 28.5.0.8
with main (4/4, exit 139) and passes with this branch (4/4). The same
input passes on OTP 28.3 and OTP 27; zig-dnssec fa8d500 crashes on 28.3
only. So OTP 28.4's fix for OTP-19951 does not cover this case, and the
removal condition in the comment was wrong. Comment and test doc now say
OTP 28 and name both reproductions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0136P7Zo6VBPrBWYUmDJZR1H
@hyperpolymath hyperpolymath changed the title Stop the OTP 28.3 segfault in scans and the RSR oracle (PinSites miscompile) Stop the OTP 28 segfault in scans and the RSR oracle (PinSites miscompile) Nov 13, 2026
@hyperpolymath
hyperpolymath marked this pull request as ready for review November 13, 2026 13:25
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T16:06:25.921287Z 171ec66 New commits
🔒 Security Review ❌ Failed 2026-11-13T16:04:08.432391Z
We couldn’t complete this review. Comment @codex security review to try again.
171ec66 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins.

@hyperpolymath
hyperpolymath enabled auto-merge (squash) November 13, 2026 15:28
@chatgpt-codex-connector

Copy link
Copy Markdown

This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins.

@chatgpt-codex-connector

Copy link
Copy Markdown

This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins.

Copy link
Copy Markdown
Owner Author

Rust Dependency Audit (and Security Status): not caused by this PR.

The audit fails on advisory RUSTSEC-2026-0538 in the crate quinn-udp, which is in Cargo.lock on main. This PR changes no Rust code and no lockfile; it changes one Elixir module and adds one Elixir test. The fix is #1071 (bump quinn-udp 0.5.14 to 0.5.16). The other crates the audit lists (astral-tokio-tar, proc-macro-error2, rustix) are warnings, not failures. Rust Dependency Audit is not a required check, so it does not block this PR.


Generated by Claude Code

hyperpolymath added a commit that referenced this pull request Nov 13, 2026
…lay corpus (#1064)

## What

Hypatia's rules read repositories. Nothing read what a failed run left
behind, so infrastructure reds (rate limits, merge-ref races, cancelled
runs, dead tokens, unreachable hosts, lock pins) looked the same as code
failures.

This PR adds `Hypatia.Rules.CiFailureTriage`:

- **19 rules**, with ids `hypatia/ci_failure_triage/<name>` (standards
A5 form, no wildcards).
- **Precedence**: four layers, platform > config > toolchain > code. The
earliest layer is the cause, so a rate limit outranks the test failure
it caused.
- **One action per rule**: `none` · `rerun` · `fix` · `owner` · `report`
· `upstream`.
- **Loop limit**: `decide/2` escalates a transient rule to the owner
(`persistent: true`) once its rerun budget is spent. Every budget is at
most 2, so a rerun loop always ends.
- **Never**: admin merge, required-check or ruleset edits, licence or
SPDX edits, loosening a canon gate, skipping tests
(`forbidden_actions/0`, and a test checks that no rule takes one).
- `check_gate/2` finds required checks that never report, and names a
near match when only the case differs.
- `check_scanner_pin_drift/1` finds panic-attack pinned at different
commits. Today it finds four: `ac68bbae` (hypatia estate-rescan),
`b689a74d` (fleet report-back), `410a8f82` (standards Hypatia lane and
fork-governance) and `b5530834` (deep-recon).
- **WF029** in `WorkflowAudit.audit/3` catches an `if: always()` job
that downloads its needs' artifacts. Such a job turns red on a cancelled
run; the recipe is `if: ${{ !cancelled() }}`. It fired once across 165
local estate workflows, on cicd-squabbler `static-analysis-gate.yml`
`deposit-findings`.
- The rules are wired to `mix hypatia.ci_triage log|gate|pins|rules`. It
runs offline, prints JSONL and exits 3 when it finds something.

## Evidence

The replay corpus in `test/fixtures/ci_failure_triage/` has 20 cases:

- 12 seed signatures reconstructed from the reported text.
- 8 real excerpts of hypatia's own failed runs, with the run id in the
file name.

The real logs first exposed five classes the rules missed: a dead PAT
(401), GitHub API 5xx, an unresolvable lock pin, a diff-range commit
missing from the checkout, and a rollup cascade. I added a rule for
each.

Fixtures are `.txt` because `.gitignore` drops `*.log`.

The segfault rule escalates instead of rerunning. The estate case is the
deterministic OTP 28 miscompile (#1062).

## Testing

I ran this locally on Elixir 1.17.3 / OTP 25, because this sandbox can't
reach repo.hex.pm. The harness leaves out the web tier and the neural
tier, and takes jason and gen_stage from git.

- `test/rules` plus every test touching WorkflowAudit or the CLI: **776
tests, 0 failures**. The baseline before this change was 571/571 in
`test/rules`.
- `mix format --check-formatted` is clean on the changed files.
- `scripts/check-readme-claims.sh` passes. README and CLAUDE.md counts
were re-measured, and `docs/rules/catalogue.adoc` was regenerated.

The full `mix test` on CI's OTP 27 lane has not been run by me. CI is
the first full run.

---
_Generated by [Claude
Code](https://claude.ai/code/session_0136P7ZkGCWGEyedTtdEHAPT)_

---------

Co-authored-by: CLAUDE <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins.

@sonarqubecloud

Copy link
Copy Markdown

Copy link
Copy Markdown
Owner Author

Validate Documentation: not caused by this PR.

The failing step is "Rule registry (hypatia_rules_praxis.deed) matches the code and lints": the committed registry is stale. The diff shows new hypatia/ci_failure_triage/* ids from #1064, which merged without regenerating the file. The same check fails on main (4815dea). This PR adds or changes no rule (only a compile option and a test), so the fix is scripts/gen-rules-praxis.sh on main; I have told the owner of #1064. Validate Documentation is not a required check.


Generated by Claude Code

@hyperpolymath
hyperpolymath merged commit 37b8d01 into main Nov 13, 2026
85 of 87 checks passed
@hyperpolymath
hyperpolymath deleted the claude/otp283-pin-sites-segfault branch November 13, 2026 16:07
hyperpolymath added a commit that referenced this pull request Nov 14, 2026
…1103)

Minted repos keep segfaulting (exit 139) in the RSR oracle and the
Hypatia scan because they pin an old Hypatia (`be98f74`), from before
the #1062 crash fix. This was confirmed by MMT/Autoformalisation on
Apodeixis.jl#25: syncing the pins from the template fixed it. The pin
sits in five places that must move together, and the template itself
splits them. This adds a static check, in the same shape as the existing
panic-attack `scanner_pin_drift`.

## What
- `check_hypatia_pin_drift/1` reads these Hypatia pin sites:
  - `HYPATIA_SHA:` env (block or flow form)
  - `--hypatia-ref <sha>`
- a checkout of `repository: hyperpolymath/hypatia` with a sibling
`ref:`, in either order
- `hypatia-rule-order.json` `scanner.commit` (only when
`scanner.repository` is `hyperpolymath/hypatia`)
- When more than one commit is pinned, it reports every site. The new
`hypatia_pin_drift` rule is report-only: routed to the owner, never
auto-fixed. YAML comments are stripped, so a kept "old pin" comment is
not a second pin. `${{ … }}` values are not pins.
- `mix hypatia.ci_triage pins` runs it alongside the panic-attack check
and accepts the policy JSON.

## Proof
On rsr-template-repo main `d183b32`, `mix hypatia.ci_triage pins
.github/workflows/*.yml
.machine_readable/policies/hypatia-rule-order.json` exits 3 and reports
all five sites: dogfood-gate's oracle at `51539ab`, and the scan, both
verdict-grid flags and the policy at `6693f9a`. On main it reports
nothing for the same files.

## Tests
- 7 new tests:
  - the template's split, with all 5 sites reported
  - one pin everywhere is clean
  - a checkout of another repository is not a Hypatia pin
  - a commented-out old pin is ignored
  - a policy naming another scanner is not a Hypatia pin
  - `ref:` before `repository:` is still read
  - a variable `HYPATIA_SHA` is not a pin

  All fail on main.
- `mix test test/rules`: 887 tests, 0 failures.
- `gen-rules-praxis.sh --check` (deed regenerated, 438 rules),
`check-readme-claims.sh` and `rules-praxis-test.sh` (22/22) are clean,
and the self-scan reports no findings.

## Not in scope
- Whether a pin contains #1062 needs the Hypatia history, so this static
check doesn't decide it.
- The template's own fix (one pin everywhere, and
`check-workflow-edges.sh` covering `dogfood-gate.yml`) belongs to
rsr-template-repo.

---
_Generated by [Claude
Code](https://claude.ai/code/session_0136P7ZkGCWGEyedTtdEHAPT)_

---------

Co-authored-by: Claude <[email protected]>
hyperpolymath pushed a commit to metadatastician/lintel that referenced this pull request Nov 17, 2026
Root cause of the exit 139 on #30: Lintel pinned Hypatia be98f74
(2026-10-27). That revision predates hyperpolymath/hypatia#1062, which
compiles Hypatia.Rules.PinSites with :no_ssa_opt_destructive_update.
Without it, the compiler's in-place binary append (`out <> <<c>>` in
PinSites.do_mask/3) corrupts the VM's writable-binary list (p->wrt_bins
head BinRef with next = 0xd8, in the core dump), and the GC crashes in
sweep_off_heap.

Both jobs that build Hypatia now use rsr-template-repo's pins, the
estate's "one Hypatia revision":
  static-analysis-gate.yml  hypatia-scan  6693f9a, OTP 27.3.4.19
                                          (strict), patch level in the
                                          cache key
  dogfood-gate.yml          rsr-score-self 6693f9a, OTP 27.3.4.19

Evidence, 44 inputs (Lintel main, the #29 and #30 merge refs, a
minimised tree and 40 random subsets of the workflows), escripts built
on each runtime:
                     27.3.4.19  28.3.3  28.5.0.8
  be98f74 (old pin)  3 crash    5 crash 3 crash
  6693f9a (new pin)  0          0       0
The scan step from this file passes on the main and #30 trees (exit 0,
critical=0 high=2 medium=5). `mix hypatia.rsr_score` on the #30 tree
passes 3/3. check-lock-sync.sh and check-invisible-characters.sh pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01J4QvDiFtqASJYm1U8JRY6P
hyperpolymath added a commit that referenced this pull request Nov 18, 2026
## What

`hypatia-cli.sh` no longer `exec`s 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.

- Lintel still pinned `be98f74`, which predates #1062. Its core dump
shows the #1062 signature: in-place binary append in
`PinSites.do_mask/3`, the head of the process's `wrt_bins` list with
`next = 0xd8`, and `sweep_off_heap` crashing in the GC.
- The fix for Lintel is metadatastician/lintel#33, which pins `6693f9a`
on OTP 27.3.4.19.
- This PR addresses the general problem: a VM crash should say so
wherever a consumer calls the wrapper.

## 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 #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](https://claude.ai/code/session_01J4QvDiFtqASJYm1U8JRY6P)_

---------

Co-authored-by: Claude <[email protected]>
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