docs(erlang): design systematic wasm32 -O2 miscompilation coverage (kd-r8h7)#832
Open
brandonpayton wants to merge 1 commit into
Conversation
Add a design handoff for kd-r8h7 under docs/plans/. Characterizes the LLVM wasm32 -O2 ESTACK/WSTACK miscompilation bug class behind the reactive -O1 downgrades in build-erlang.sh (erl_unicode, erl_db_util, erl_db_hash, erl_db; erl_bif_chksum via PR #824), and proposes a three-layer strategy: - Detection: a CI-gated on-Kandelo term/iodata smoke matrix (batched into one BEAM boot) so a new miscompilation fails fast instead of shipping silently. - Containment: a greppable workaround registry + a one-time ESTACK/WSTACK risk audit, keeping the reactive process systematic and bounded (not blanket -O1). - Root cause: a minimal reproducer + upstream LLVM/OTP report with explicit -O1 removal criteria. Design only; implements none of the coverage, smoke, audit, or upstream work. Follow-up to kd-qe2c (PR #824). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Design handoff for
kd-r8h7(follow-up tokd-qe2c/ PR #824). Addsdocs/plans/2026-07-02-erlang-wasm32-o2-miscompilation-coverage-design.md.Design only — no coverage, smoke, audit, or upstream work is implemented here.
Why
build-erlang.shcompiles a growing, reactively discovered set of ERTS filesat
-O1to dodge LLVM wasm32-O2miscompilations (erl_unicode,erl_db_util,erl_db_hash,erl_db;erl_bif_chksumvia PR #824). Each wasfound only when a user hit it — the
erlang:md5/1-over-iolist case even brokeon-Kandelo compilation entirely. Other term/iodata-walking files may harbor the
same defect and ship silently until tripped.
The design
-O2miscompiles the ESTACK/WSTACK term-traversalidiom (a control struct whose pointer fields alias a shadow-stack local
array). Two facets — aggregate initialization (fixed globally in
global.h)and optimized traversal codegen (worked around per-file with
-O1). Theinit patch is necessary but not sufficient.
into one BEAM boot, so a new miscompilation fails fast; (B) a greppable
workaround registry + a one-time ESTACK/WSTACK risk audit to make the reactive
process systematic and bounded — explicitly not blanket
-O1; (C) a minimalreproducer + upstream LLVM/OTP report with concrete
-O1removal criteria.erlang.test.tsisskipIf(!hasErlang)anddoes not run in CI; the authoritative gate must run where the OTP runtime tree
(
erlang-otp.tar.zst) is present.Implementation sequence is broken into candidate child beads; steps 1–4 deliver
the core value at low risk.
🤖 Generated with Claude Code