rustc SIGSEGVs in LLVM's WebAssemblyLateEHPrepare::runOnMachineFunction
pass when compiling a small Rust crate for wasm32-unknown-unknown with
-Cpanic=unwind, target-feature=+exception-handling, and a -Zbuild-std-rebuilt
libstd. The crash seems to have been introduced in the same nightly that landed
#156061 "Support -Cpanic=unwind on WASI targets".
A 254LOC self-contained reproducer follows below (this is at the point where we gave up.
Apologies if it remains too large; it's originally a 300kLOC project)
Code
Cargo.toml:
[package]
name = "repro_rust_156061"
version = "0.0.0"
edition = "2024"
[dependencies]
serde_json = "1"
hashlink = "0.11.0"
[profile.release]
opt-level = 3
codegen-units = 16
rust-toolchain.toml:
[toolchain]
channel = "nightly-2026-05-09" # first-known-bad; nightly-2026-05-08 builds cleanly
components = ["rust-src", "rustfmt", "clippy"]
targets = ["wasm32-unknown-unknown"]
.cargo/config.toml:
[target.wasm32-unknown-unknown]
rustflags = ["-C", "target-feature=+bulk-memory,+exception-handling",
"-C", "panic=unwind",
"-Zwasm-c-abi=spec"]
[unstable]
build-std = ["std", "panic_unwind"]
src/lib.rs (254 LOC, all type definitions; method bodies are loop {}):
use hashlink::LinkedHashMap;
use serde_json::Value;
#[derive(Debug, Clone, PartialEq)]
pub(crate) enum SourceInfo {
Original(Vec<u8>),
}
pub(crate) type Attr = (String, Vec<String>, LinkedHashMap<String, String>);
#[derive(Debug, Clone, PartialEq)]
pub(crate) enum ShortcodeArg {
String(),
Number(),
Boolean(),
Shortcode(),
KeyValue(),
}
#[derive(Debug, Clone, PartialEq)]
pub(crate) struct Shortcode {
pub(crate) keyword_args: LinkedHashMap<String, ShortcodeArg>,
}
#[derive(Debug, Clone, PartialEq)]
pub(crate) enum Block {
Plain(), Paragraph(), LineBlock(), CodeBlock(), RawBlock(),
BlockQuote(), OrderedList(), BulletList(), DefinitionList(),
Header(), HorizontalRule(), Table(), Figure(), Div(),
BlockMetadata(), NoteDefinitionPara(), NoteDefinitionFencedBlock(),
CaptionBlock(), Custom(),
}
pub(crate) type Blocks = Vec<Block>;
#[derive(Debug, Clone, PartialEq)]
pub(crate) enum Slot {
Block(Box<Block>),
Inline(Box<Inline>),
Blocks(Blocks),
Inlines(Inlines),
}
#[derive(Debug, Clone, PartialEq)]
pub struct CustomNode {
pub(crate) slots: LinkedHashMap<String, Slot>,
pub(crate) plain_data: Value,
}
impl CustomNode {
pub(crate) fn new(type_name: impl Into<String>, attr: Attr, source_info: SourceInfo) -> Self { loop { } }
pub(crate) fn with_slot(mut self, name: impl Into<String>, slot: Slot) -> Self { loop { } }
pub fn with_data(mut self, data: Value) -> Self { self.plain_data = data; self }
pub(crate) fn get_slot(&self, name: &str) -> Option<&Slot> { loop { } }
pub(crate) fn get_slot_mut(&mut self, name: &str) -> Option<&mut Slot> { loop { } }
pub(crate) fn set_slot(&mut self, name: impl Into<String>, slot: Slot) { loop { } }
pub(crate) fn has_block_slots(&self) -> bool { loop { } }
}
#[derive(Debug, Clone, PartialEq)]
pub(crate) enum Inline {
Str(Str), Emph(Emph), Underline(Underline), Strong(Strong), Strikeout(Strikeout),
Superscript(Superscript), Subscript(Subscript), SmallCaps(SmallCaps),
Quoted(Quoted), Cite(Cite), Code(Code), Space(Space), SoftBreak(SoftBreak),
LineBreak(LineBreak), Math(Math), RawInline(RawInline), Link(Link), Image(Image),
Note(Note), Span(Span), Shortcode(Shortcode), NoteReference(NoteReference),
Attr(InlineAttr), Insert(Insert), Delete(Delete), Highlight(Highlight),
EditComment(EditComment), Custom(CustomNode),
}
pub(crate) type Inlines = Vec<Inline>;
#[derive(Debug, Clone, PartialEq)] pub(crate) struct Str { pub(crate) source_info: SourceInfo }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct Emph { pub(crate) content: Inlines }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct Underline {}
#[derive(Debug, Clone, PartialEq)] pub(crate) struct Strong {}
#[derive(Debug, Clone, PartialEq)] pub(crate) struct Strikeout { pub(crate) content: Inlines }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct Superscript {}
#[derive(Debug, Clone, PartialEq)] pub(crate) struct Subscript {}
#[derive(Debug, Clone, PartialEq)] pub(crate) struct SmallCaps { pub(crate) content: Inlines }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct Quoted { pub(crate) content: Inlines }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct Cite { pub(crate) citations: Vec<Citation> }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct Code { pub(crate) attr: Attr }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct Math { pub(crate) source_info: SourceInfo }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct RawInline { pub(crate) format: String }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct Link { pub(crate) attr: Attr }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct Image { pub(crate) attr: Attr }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct Note { pub(crate) content: Blocks }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct Span { pub(crate) attr: Attr }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct Space { pub(crate) source_info: SourceInfo }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct LineBreak { pub(crate) source_info: SourceInfo }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct SoftBreak { pub(crate) source_info: SourceInfo }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct NoteReference { pub(crate) id: String }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct Citation { pub(crate) hash: usize }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct Insert { pub(crate) attr: Attr }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct Delete { pub(crate) attr: Attr }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct Highlight { pub(crate) attr: Attr }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct EditComment { pub(crate) attr: Attr }
#[derive(Debug, Clone, PartialEq)] pub(crate) struct InlineAttr { pub(crate) attr: Attr }
In full disclosure, this reproducer was assembled with the help of cargo-minimize and Claude Opus's 4.7.
Meta
rustc --version --verbose:
rustc 1.97.0-nightly (fb0a5a5a9 2026-05-08)
binary: rustc
commit-hash: fb0a5a5a9c892b351f34263d6d84da9dde72871a
commit-date: 2026-05-08
host: aarch64-apple-darwin
release: 1.97.0-nightly
LLVM version: 22.1.4
We also noticed this happens on linux x86_64-unknown-linux-gnu (on GH CI specifically), but the minimization step
here was done entirely on macOS in case that matters.
Error output
$ cargo build --target wasm32-unknown-unknown --release
Compiling repro_rust_156061 v0.0.0 (/private/tmp/repro-rust-156061)
warning: unstable feature specified for `-Ctarget-feature`: `exception-handling`
|
= note: this feature is not stably supported; its behavior can change in the future...
...
lots of warnings
...
backtrace below
...
note: we would appreciate a report at https://github.com/rust-lang/rust
help: you can increase rustc's stack size by setting RUST_MIN_STACK=16777216
warning: `repro_rust_156061` (lib) generated 17 warnings (run `cargo fix --lib -p repro_rust_156061` to apply 10 suggestions)
error: could not compile `repro_rust_156061` (lib); 17 warnings emitted
Caused by:
process didn't exit successfully: `/Users/cscheid/.rustup/toolchains/nightly-2026-05-09-aarch64-apple-darwin/bin/rustc --crate-name repro_rust_156061 --edition=2024 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=239 --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C codegen-units=16 --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=d7b8a8888359b918 -C extra-filename=-ab39d4b35da2aa86 --out-dir /private/tmp/repro-rust-156061/target/wasm32-unknown-unknown/release/deps --target wasm32-unknown-unknown -C strip=debuginfo -L dependency=/private/tmp/repro-rust-156061/target/wasm32-unknown-unknown/release/deps -L dependency=/private/tmp/repro-rust-156061/target/release/deps --extern 'noprelude,nounused:alloc=/private/tmp/repro-rust-156061/target/wasm32-unknown-unknown/release/deps/liballoc-ed1c819a2703fed6.rmeta' --extern 'noprelude,nounused:compiler_builtins=/private/tmp/repro-rust-156061/target/wasm32-unknown-unknown/release/deps/libcompiler_builtins-77a865dc1275a294.rmeta' --extern 'noprelude,nounused:core=/private/tmp/repro-rust-156061/target/wasm32-unknown-unknown/release/deps/libcore-2e9b440d3fc82546.rmeta' --extern hashlink=/private/tmp/repro-rust-156061/target/wasm32-unknown-unknown/release/deps/libhashlink-2d6394660be659f3.rmeta --extern 'noprelude,nounused:panic_unwind=/private/tmp/repro-rust-156061/target/wasm32-unknown-unknown/release/deps/libpanic_unwind-d03a2151cbd10a12.rmeta' --extern 'noprelude,nounused:proc_macro=/private/tmp/repro-rust-156061/target/wasm32-unknown-unknown/release/deps/libproc_macro-e13fce760a3f6a76.rmeta' --extern serde_json=/private/tmp/repro-rust-156061/target/wasm32-unknown-unknown/release/deps/libserde_json-ecd630df5993dedf.rmeta --extern 'noprelude,nounused:std=/private/tmp/repro-rust-156061/target/wasm32-unknown-unknown/release/deps/libstd-1d0a92353460ed17.rmeta' -Z unstable-options -C target-feature=+bulk-memory,+exception-handling -C panic=unwind -Zwasm-c-abi=spec` (signal: 11, SIGSEGV: invalid memory reference)
We note that we attempted to increase the stack size up to 256MB with no difference in the output.
Backtrace
error: rustc interrupted by SIGSEGV, printing backtrace
0 librustc_driver-88b6a3a0e1540a1f.dy 0x000000010d6d8a40 _RNvNtCsjcUzn6Sffq8_17rustc_driver_impl14signal_handler17print_stack_trace + 140
1 libsystem_platform.dylib 0x00000001854317a4 _sigtramp + 56
2 librustc_driver-88b6a3a0e1540a1f.dy 0x000000010fde64b4 _ZN12_GLOBAL__N_124WebAssemblyLateEHPrepare20runOnMachineFunctionERN4llvm15MachineFunctionE + 3728
3 librustc_driver-88b6a3a0e1540a1f.dy 0x0000000111a71110 _ZN4llvm19MachineFunctionPass13runOnFunctionERNS_8FunctionE + 728
4 librustc_driver-88b6a3a0e1540a1f.dy 0x000000011278b03c _ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE + 608
5 librustc_driver-88b6a3a0e1540a1f.dy 0x0000000112791318 _ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE + 60
6 librustc_driver-88b6a3a0e1540a1f.dy 0x000000011278b9ec _ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE + 2060
7 librustc_driver-88b6a3a0e1540a1f.dy 0x00000001129fab0c LLVMRustWriteOutputFile + 488
8 librustc_driver-88b6a3a0e1540a1f.dy 0x000000010d308aec _RNvNtNtCsc9Bu5jgT1Xe_18rustc_codegen_llvm4back5write17write_output_file + 264
9 librustc_driver-88b6a3a0e1540a1f.dy 0x000000010d30bf8c _RNvNtNtCsc9Bu5jgT1Xe_18rustc_codegen_llvm4back5write7codegen + 3348
10 librustc_driver-88b6a3a0e1540a1f.dy 0x000000010d341e0c _RNvXs1_Csc9Bu5jgT1Xe_18rustc_codegen_llvmNtB5_18LlvmCodegenBackendNtNtNtCscuQD1gg67ie_17rustc_codegen_ssa6traits5write19WriteBackendMethods25optimize_and_codegen_thin + 2488
11 librustc_driver-88b6a3a0e1540a1f.dy 0x000000010d278060 _RINvNtNtCs21fcyVcIRm3_3std3sys9backtrace28___rust_begin_short_backtraceNCINvNtNtCscuQD1gg67ie_17rustc_codegen_ssa4back5write19spawn_thin_lto_workNtCsc9Bu5jgT1Xe_18rustc_codegen_llvm18LlvmCodegenBackendE0uEB2l_ + 432
12 librustc_driver-88b6a3a0e1540a1f.dy 0x000000010d2b63ac _RNSNvYNCINvNtNtCs21fcyVcIRm3_3std6thread9lifecycle15spawn_uncheckedNCINvNtNtCscuQD1gg67ie_17rustc_codegen_ssa4back5write19spawn_thin_lto_workNtCsc9Bu5jgT1Xe_18rustc_codegen_llvm18LlvmCodegenBackendE0uEs_0INtNtNtCsbThQ9rNIyNR_4core3ops8function6FnOnceuE9call_once6vtableB2h_ + 144
13 librustc_driver-88b6a3a0e1540a1f.dy 0x000000010f9f484c _RNvNvMs0_NtNtNtCs21fcyVcIRm3_3std3sys6thread4unixNtB7_6Thread3new12thread_start + 400
14 libsystem_pthread.dylib 0x0000000185427c58 _pthread_start + 136
15 libsystem_pthread.dylib 0x0000000185422c1c thread_start + 8
etc.
We've bisected to that PR with cargo-bisect-rustc v0.6.11.
In case it's easier for you to debug, there's a repo you can consult more directly.
Let me know if you want more details as well.
cc @alexcrichton (PR #156061 author)
rustcSIGSEGVs in LLVM'sWebAssemblyLateEHPrepare::runOnMachineFunctionpass when compiling a small Rust crate for
wasm32-unknown-unknownwith-Cpanic=unwind,target-feature=+exception-handling, and a-Zbuild-std-rebuiltlibstd. The crash seems to have been introduced in the same nightly that landed
#156061 "Support
-Cpanic=unwindon WASI targets".A 254LOC self-contained reproducer follows below (this is at the point where we gave up.
Apologies if it remains too large; it's originally a 300kLOC project)
Code
Cargo.toml:rust-toolchain.toml:.cargo/config.toml:src/lib.rs(254 LOC, all type definitions; method bodies areloop {}):In full disclosure, this reproducer was assembled with the help of cargo-minimize and Claude Opus's 4.7.
Meta
rustc --version --verbose:We also noticed this happens on linux
x86_64-unknown-linux-gnu(on GH CI specifically), but the minimization stephere was done entirely on macOS in case that matters.
Error output
We note that we attempted to increase the stack size up to 256MB with no difference in the output.
Backtrace
etc.
We've bisected to that PR with
cargo-bisect-rustcv0.6.11.In case it's easier for you to debug, there's a repo you can consult more directly.
Let me know if you want more details as well.
cc @alexcrichton (PR #156061 author)