Repository navigation
Fix startup SIGILL on Linux arm64 when SVE2 is reported without SVE - #45099
Conversation
|
Updated 6:42 PM PT - Oct 12th, 2026
@dylan-conway, your commit 4bc76c7 is building: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughHighway’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. ChangesSVE2 Detection Guard
Suggested reviewers: Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to 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 ·
|
There was a problem hiding this comment.
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"], |
There was a problem hiding this comment.
🔴 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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
🟡 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.
There was a problem hiding this comment.
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.
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.
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_SVE2from 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.Highway, the SIMD library behind Bun's string search, read
HWCAP2_SVE2alone and then rancntb, an SVE instruction, to measure the vector length. The fix is one condition inhwy/targets.cc, carried aspatches/highway/sve2-requires-sve.patchbecause 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?
qemu-aarch647.2 with-cpu max,sve=off, which reports these flags: SIGILL at thecntb.max,sve=offchanges (SIGILL, thenNEON_BF16).max,sve-max-vq=1still getsSVE2_128.arch/arm64/kernel/cpufeature.cat 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.