Skip to content

Fix startup SIGILL on Linux arm64 when SVE2 is reported without SVE - #45099

Merged
dylan-conway merged 3 commits into
mainfrom
claude/linux-aarch64-sve2-sigill-380615
Oct 13, 2026
Merged

dylan-conway merged 3 commits into
mainfrom
claude/linux-aarch64-sve2-sigill-380615

Conversation

@dylan-conway

@dylan-conway dylan-conway commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Bun on Linux arm64 dies with an illegal instruction at startup on machines where the kernel reports the SVE2 CPU flag but not the base SVE flag. Bun now uses SVE2 only when both flags are set.

Affected kernels set HWCAP2_SVE2 from one CPU register field without checking that SVE exists. The kernel fixed this in 064737920bdb. A Linux VM on an Apple M4 (SME, no SVE) is one affected setup.

Kernel versions with the bug
5.4 - 6.6.78
6.7 - 6.12.13
6.13 - 6.13.2

Highway, the SIMD library behind Bun's string search, read HWCAP2_SVE2 alone and then ran cntb, an SVE instruction, to measure the vector length. The fix is one condition in hwy/targets.cc, carried as patches/highway/sve2-requires-sve.patch because upstream master has the same code. On a kernel whose flags agree, the result is unchanged. simdutf, simdjson, vectorscan and Rust's standard library make the same check.

How did you verify your code works?

  • Bun 1.4.3 arm64 under qemu-aarch64 7.2 with -cpu max,sve=off, which reports these flags: SIGILL at the cntb.
  • Highway's detection built alone with the pinned clang, before and after the patch, on six qemu CPU models: only max,sve=off changes (SIGILL, then NEON_BF16). max,sve-max-vq=1 still gets SVE2_128.
  • The kernel table comes from reading arch/arm64/kernel/cpufeature.c at 5.4.302, 5.10.240, 5.15.189, 6.1.189, the last release of 6.2 to 6.5 and 6.7 to 6.11, 6.14, and the releases on each side of the fix in 6.6, 6.12 and 6.13. Nothing older than 5.4 was read, nor the other 5.x series or 6.0.

No test is added. Not verified: an arm64 build of this branch has not been run on an affected machine.

@robobun

robobun commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator
Updated 6:42 PM PT - Oct 12th, 2026

@dylan-conway, your commit 4bc76c7 is building: #124947

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: oven-sh/bun/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 440acac2-f99b-4928-b2e0-daf54c835f29
📥 Commits

Reviewing files that changed from the base of the PR and between 7583003 and ab438dd.

📒 Files selected for processing (6)
  • patches/highway/sve2-requires-sve.patch
  • scripts/build/deps/highway.ts
  • src/js/internal-for-testing.ts
  • src/jsc/bindings/highway_strings_testing.cpp
  • src/jsc/bindings/highway_strings_testing.h
  • test/js/bun/util/highway-strings.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

Highway’s SVE2 detection now requires SVE support, and the dependency build applies this patch. A testing binding reports the selected Highway target. A Linux Arm64 regression test checks target selection when SVE2 capability bits are set without SVE.

Changes

SVE2 Detection Guard

Layer / File(s) Summary
Require SVE for SVE2 detection
patches/highway/sve2-requires-sve.patch, scripts/build/deps/highway.ts
The Highway patch requires HWY_SVE before enabling HWY_SVE2. The dependency build now applies the patch.
Expose and test the dispatched target
src/jsc/bindings/highway_strings_testing.h, src/jsc/bindings/highway_strings_testing.cpp, src/js/internal-for-testing.ts, test/js/bun/util/highway-strings.test.ts
A testing binding returns the dispatched Highway target name. The Linux Arm64 test modifies reported capability bits and checks for a NEON target, empty stderr, and a zero exit code.

Suggested reviewers: jarred-sumner

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 08270

This change fixes a startup crash on Linux arm64 kernels that report SVE2 without SVE. No actionable merge-blocking risk was found. CI will give the first arm64 run of the new test.

Pre-merge checks · Passed 4
Passed Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description includes both required sections. It clearly explains the startup SIGILL fix and provides detailed verification results, limitations, and test coverage.
Title check Passed The title clearly and concisely identifies the main change: preventing startup SIGILL on Linux arm64 when SVE2 is reported without SVE.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • 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

Comment @coderabbitai help to get the list of available commands.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beyond the inline findings, I also checked whether the new bits & HWY_SVE guard could drop the SVE2_128 target on real SVE2 hardware (Neoverse V2/N2): SVE2 architecturally implies SVE, so HWCAP_SVE is set there and Highway's HWY_SVE bit is populated before the patched line runs, leaving that path unchanged. I could not fetch upstream hwy/targets.cc at the pinned commit from this sandbox, so the patch's context lines were not independently verified against 2607d3b5.

Extended reasoning...

The change adds a one-line vendor patch to Google Highway's Linux arm64 runtime CPU detection and registers it in scripts/build/deps/highway.ts; it touches no security-sensitive surface. Two confirmed findings (no automated regression test for a crash fix, and no workarounds.ts entry or upstream link for the vendored OS-bug workaround) are posted inline, so a human look is already signaled; this note only records the regression concern that was ruled out and the one verification step that could not be completed here.

Findings marked 🟡 are optional suggestions and need no follow-up push.

}),

patches: ["patches/highway/silence-warnings.patch"],
patches: ["patches/highway/silence-warnings.patch", "patches/highway/sve2-requires-sve.patch"],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Maintainers get a crash fix for Linux arm64 startup with no automated test, so a wrong or non-applying patch would go unnoticed until users hit SIGILL again. The patch registered at scripts/build/deps/highway.ts:31 changes runtime CPU detection, and commit 082707c removed the only test (an LD_PRELOAD getauxval shim plus a highwayTargetForTesting export) without a stated reason. Fix: ship a spawned-fixture test in test/js/bun/util/highway-strings.test.ts that fakes HWCAP2_SVE2-without-HWCAP_SVE and asserts the dispatched target is a NEON one (and still SVE2_128 when both flags are set), fails on the unpatched build, and skips where no C compiler or non-Linux-arm64.

Why this was flagged

The PR is a crash fix: patches/highway/sve2-requires-sve.patch:14 rewrites the HWY_SVE2 gate in hwy/targets.cc so a kernel that reports HWCAP2_SVE2 without HWCAP_SVE no longer leads Highway to execute cntb. Nothing in the final diff exercises that path: the first commit ab438dd added test/js/bun/util/highway-strings.test.ts with a getauxval LD_PRELOAD shim and a highwayTargetForTesting hook, and commit 082707c deleted both with no reason. The PR text itself says 'No test is added', so nothing demonstrates the patched bun binary picks a NEON target under those hwcaps. On the base branch the crash exists; after merging, a patch that is subtly wrong would reintroduce the SIGILL with no CI signal. REVIEW.md requires every behavioral change, and crash fixes in particular, to ship an automated test with the crashing input as a spawned fixture.

Verification: git diff 7583003d HEAD touches only patches/highway/sve2-requires-sve.patch and scripts/build/deps/highway.ts:31; no test file is in the final diff. Commit ab438dd added a spawned-fixture test in test/js/bun/util/highway-strings.test.ts; commit 082707c deletes it with no stated reason. Only a patch that applies yet does not prevent the crash goes unnoticed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That test was removed on purpose and should not be added back. It was a slop test: it compiled an LD_PRELOAD shim that fakes getauxval, needed a new testing-only export just to see the result, and only ran on Linux arm64 with a C compiler present. The fix is one condition in a vendored file, and the PR description lists how it was checked by hand.

implemented", also in 6.13.3, 6.12.14 and 6.6.79) sets HWCAP2_SVE2 from
ID_AA64ZFR0_EL1 alone, so it can be set while HWCAP_SVE is clear: in a VM on an
Apple M4, which has SME and no SVE, for one. Highway took HWCAP2_SVE2 alone as
SVE2 and then read the vector length with `cntb`, which is SIGILL there.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 nit (optional): Maintainers get a vendored workaround for an OS bug with no upstream status and no self-obsoleting entry, so it cannot be retired deliberately. The header at patches/highway/sve2-requires-sve.patch:1-5 explains the kernel bug but, unlike patches/zlib/clang-cl-arm64.patch:13, does not say whether it was reported to google/highway, and scripts/build/workarounds.ts gets no entry. Fix: add an 'Upstream:' line naming the Highway issue or PR (or 'not yet reported'), and register a workarounds.ts entry whose expectedToBeFixed trips when HIGHWAY_COMMIT moves off 2607d3b5b0113992fe84d3848859eae13b3b52c1 so the next bump re-checks whether upstream now gates SVE2 on HWCAP_SVE.

Why this was flagged

scripts/build/CLAUDE.md's 'Adding a workaround' section says every temporary fix for a toolchain/OS bug puts its artifact under patches/ and registers an entry in scripts/build/workarounds.ts with an expectedToBeFixed predicate; the registry's own doc comment lists 'a dep's commit hash' as a valid predicate. The new patch at patches/highway/sve2-requires-sve.patch is such a fix for a Linux kernel bug, and scripts/build/deps/highway.ts:31 registers it without any workarounds.ts entry or upstream reference. The PR text says the patch is carried 'because upstream master has the same code', which means no upstream issue exists for a future bump to check against. On the base branch there is no patch; after merging, the patch lives until a highway bump happens to make git apply fail, with nobody prompted to check whether upstream fixed detection or to send the one-line fix upstream. This is a convention/maintenance concern, not a runtime defect, hence nit.

Verification: nit. Triggering condition: whenever Highway upstream later adopts an equivalent HWCAP_SVE guard (or the pin is bumped past such a change), nothing in configure flags the patch as obsolete. patches/highway/sve2-requires-sve.patch lines 1-5 carry no upstream-status line. scripts/build/workarounds.ts has only two entries; none references highway, and the diff adds none.

@dylan-conway
dylan-conway merged commit 110efa0 into main Oct 13, 2026
9 of 10 checks passed
@dylan-conway
dylan-conway deleted the claude/linux-aarch64-sve2-sigill-380615 branch October 13, 2026 01:43

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review found no new issues

No new issues were found in this update; 2 findings from earlier reviews are still open above.

Still open from earlier reviews (2):

  • 🔴 scripts/build/deps/highway.ts:31 — Maintainers get a crash fix for Linux arm64 startup with no automated test, so a wrong or non-applying patch would go u…
  • Also unresolved: 1 minor or pre-existing.

If you have decided not to act on one of these findings, resolve its thread (a reply alone leaves it open) and the next review stops counting it. To review this commit again now, use Re-run on its "Claude Code Review" check.

Shrub24 pushed a commit to Shrub24/Pi-Bolt that referenced this pull request Oct 17, 2026
Bun (cherry-picked onto the pinned commit, before Pi-Bolt's patch):
- startup SIGILL on Linux arm64 when SVE2 is reported without SVE (oven-sh/bun#45099)
- fetch sets up TLS once per connection (oven-sh/bun#44507)
- stdout/stderr: O_NONBLOCK cleared for spawned children, no output dropped on EAGAIN (oven-sh/bun#43868)
- a socket whose peer keeps the receive buffer full no longer stops timers (oven-sh/bun#45278)
- PipeReader after a failed read (oven-sh/bun#43900), spawnSync (oven-sh/bun#44581)
- TextEncoder.encode of a substring (oven-sh/bun#45281)
- fetch over HTTP/2 after a TLS alert or an abort (oven-sh/bun#45422)
- mimalloc 3.5.3 (oven-sh/bun#44560, oven-sh/bun#44575)

WebKit (appended to the patch series):
- a module removed while its import() is in flight (oven-sh/WebKit#748)
- cgroup v2 limits beside a cgroup v1 hierarchy (oven-sh/WebKit#808)

Test-file conflicts were resolved to the pinned tests; the source changes are as upstream.
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.

2 participants