bytecodealliance / wasmtime

A fast and secure runtime for WebAssembly
https://wasmtime.dev/
Apache License 2.0
15.34k stars 1.3k forks source link

Cranelift: wasmtime tests crash when logging is enabled #6333

Closed T0b1-iOS closed 1 year ago

T0b1-iOS commented 1 year ago

Hey everyone.

I noticed that when running the component_model::strings::roundtrip test like so (current main):

RUST_LOG=trace cargo test -j 1 "component_model::strings::roundtrip"

the test fails due to a panic in the pretty printing of the MachInsts:

Last bit of the log output ``` 2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] about to lower function: function u0:0(i64 vmctx, i64, i64, i64) system_v { sig0 = (i64 vmctx, i64, i32, i32, i32) fast fn0 = colocated u0:5 sig0 block0(v0: i64, v1: i64, v2: i64, v3: i64): v13 = iconst.i64 3 v4 = icmp uge v3, v13 ; v13 = 3 brif v4, block2, block1 block1 cold: trap user65535 block2: v5 = load.i32 notrap aligned little v2 v6 = load.i32 notrap aligned little v2+16 v7 = load.i32 notrap aligned little v2+32 v8 = load.i32 notrap aligned little v0 v14 = iconst.i32 0x6572_6f63 v9 = icmp eq v8, v14 ; v14 = 0x6572_6f63 brif v9, block4, block3 block3 cold: trap user65535 block4: v10 = load.i64 notrap aligned v0+8 v11 = get_stack_pointer.i64 store notrap aligned v11, v10+40 call fn0(v0, v1, v5, v6, v7) v16 = iconst.i8 1 brif v16, block6, block5 ; v16 = 1 block5 cold: trap user65535 block6: return } [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] lower_clif_block: block block6 inst inst14 (MultiAry { opcode: Return, args: EntityList { index: 0, unused: PhantomData } }) is_branch false side_effect true value_needed false [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] lowering: inst inst14: MultiAry { opcode: Return, args: EntityList { index: 0, unused: PhantomData } } [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] emit: ret [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] lower_clif_block: block block5 inst inst20 (Trap { opcode: Trap, code: User(65535) }) is_branch false side_effect true value_needed false [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] lowering: inst inst20: Trap { opcode: Trap, code: User(65535) } [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] emit: ud2 user65535 [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] lower_clif_branches: block block4 branch inst13 targets [MachLabel(6), MachLabel(5)] [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] put_value_in_regs: val v16 [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] -> regs ValueRegs { parts: [v142, v2097151] } [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] emit: testb %v142b, %v142b [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] emit: jnz label6; j label5 [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] lower_clif_block: block block4 inst inst13 (Brif { opcode: Brif, arg: v16, blocks: [BlockCall { values: EntityList { index: 81, unused: PhantomData } }, BlockCall { values: EntityList { index: 85, unused: PhantomData } }] }) is_branch true side_effect true value_needed false [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] lower_clif_block: block block4 inst inst21 (UnaryImm { opcode: Iconst, imm: Imm64(1) }) is_branch false side_effect false value_needed true [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] lowering: inst inst21: UnaryImm { opcode: Iconst, imm: Imm64(1) } [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] emit: movl $1, %v143l [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] set vreg alias: from v142 to v143 [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] lower_clif_block: block block4 inst inst11 (Call { opcode: Call, args: EntityList { index: 41, unused: PhantomData }, func_ref: fn0 }) is_branch false side_effect true value_needed false [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] lowering: inst inst11: Call { opcode: Call, args: EntityList { index: 41, unused: PhantomData }, func_ref: fn0 } [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] put_value_in_regs: val v0 [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] -> regs ValueRegs { parts: [v128, v2097151] } [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] put_value_in_regs: val v1 [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] -> regs ValueRegs { parts: [v129, v2097151] } [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] put_value_in_regs: val v5 [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] -> regs ValueRegs { parts: [v134, v2097151] } [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] put_value_in_regs: val v6 [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] -> regs ValueRegs { parts: [v135, v2097151] } [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] put_value_in_regs: val v7 [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] -> regs ValueRegs { parts: [v136, v2097151] } [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] emit: call User(userextname0) [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] lower_clif_block: block block4 inst inst10 (Store { opcode: Store, args: [v11, v10], flags: MemFlags { bits: 3 }, offset: Offset32(40) }) is_branch false side_effect true value_needed false [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] lowering: inst inst10: Store { opcode: Store, args: [v11, v10], flags: MemFlags { bits: 3 }, offset: Offset32(40) } [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] put_value_in_regs: val v10 [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] -> regs ValueRegs { parts: [v140, v2097151] } [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] put_value_in_regs: val v11 [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] -> regs ValueRegs { parts: [v141, v2097151] } [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] emit: movq %v141, 40(%v140) [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] lower_clif_block: block block4 inst inst9 (NullAry { opcode: GetStackPointer }) is_branch false side_effect false value_needed true [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] lowering: inst inst9: NullAry { opcode: GetStackPointer } [2023-05-02T23:13:42Z TRACE cranelift_codegen::machinst::lower] emit: [2023-05-02T23:13:42Z DEBUG cranelift_codegen::timing] timing: Ending VCode lowering [2023-05-02T23:13:42Z DEBUG cranelift_codegen::timing] timing: Ending Compilation passes test component_model::strings::roundtrip ... FAILED failures: ---- component_model::strings::roundtrip stdout ---- src=utf8 dst=utf8 thread '' panicked at 'called `Option::unwrap()` on a `None` value', cranelift/codegen/src/machinst/reg.rs:499:32 ---- component_model::strings::roundtrip stdout ---- src=utf8 dst=utf8 thread '' panicked at 'called `Option::unwrap()` on a `None` value', cranelift/codegen/src/machinst/reg.rs:499:32 stack backtrace: 0: rust_begin_unwind at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:579:5 1: core::panicking::panic_fmt at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/panicking.rs:64:14 2: core::panicking::panic at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/panicking.rs:114:5 3: core::option::Option::unwrap at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/option.rs:942:21 4: cranelift_codegen::machinst::reg::AllocationConsumer::next_fixed_nonallocatable at ./cranelift/codegen/src/machinst/reg.rs:499:26 5: cranelift_codegen::isa::x64::inst::::pretty_print at ./cranelift/codegen/src/isa/x64/inst/mod.rs:1421:17 6: cranelift_codegen::isa::x64::inst::::pretty_print_inst at ./cranelift/codegen/src/isa/x64/inst/mod.rs:2639:9 7: cranelift_codegen::isa::x64::inst::::fmt at ./cranelift/codegen/src/isa/x64/inst/mod.rs:1856:13 8: core::fmt::write at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/fmt/mod.rs:1232:17 9: ::fmt at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/fmt/mod.rs:559:9 10: <&T as core::fmt::Display>::fmt at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/fmt/mod.rs:2396:62 11: core::fmt::write at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/fmt/mod.rs:1232:17 12: std::io::Write::write_fmt at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/io/mod.rs:1684:15 13: env_logger::fmt::DefaultFormat::write_args at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/env_logger-0.10.0/src/fmt/mod.rs:383:21 14: env_logger::fmt::DefaultFormat::write at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/env_logger-0.10.0/src/fmt/mod.rs:232:9 15: env_logger::fmt::Builder::build::{{closure}} at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/env_logger-0.10.0/src/fmt/mod.rs:199:17 16: as core::ops::function::Fn>::call at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/alloc/src/boxed.rs:2001:9 17: ::log::{{closure}} at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/env_logger-0.10.0/src/lib.rs:924:21 18: ::log::{{closure}} at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/env_logger-0.10.0/src/lib.rs:943:33 19: std::thread::local::LocalKey::try_with at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/thread/local.rs:446:16 20: ::log at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/env_logger-0.10.0/src/lib.rs:930:27 21: log::__private_api_log at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.4.17/src/lib.rs:1597:5 22: cranelift_codegen::machinst::lower::Lower::emit at ./cranelift/codegen/src/machinst/lower.rs:1306:9 23: cranelift_codegen::isa::x64::lower::isle::>::emit at ./cranelift/codegen/src/isa/x64/lower/isle.rs:322:9 24: cranelift_codegen::isa::x64::lower::isle::generated_code::constructor_mov_from_preg at ./target/debug/build/cranelift-codegen-61ca11645288c876/out/isle_x64.rs:9515:14 25: cranelift_codegen::isa::x64::lower::isle::generated_code::constructor_x64_rsp at ./target/debug/build/cranelift-codegen-61ca11645288c876/out/isle_x64.rs:9547:14 26: cranelift_codegen::isa::x64::lower::isle::generated_code::constructor_lower at ./target/debug/build/cranelift-codegen-61ca11645288c876/out/isle_x64.rs:14422:33 27: cranelift_codegen::isa::x64::lower::isle::lower at ./cranelift/codegen/src/isa/x64/lower/isle.rs:63:5 28: cranelift_codegen::isa::x64::lower::::lower at ./cranelift/codegen/src/isa/x64/lower.rs:313:9 29: cranelift_codegen::machinst::lower::Lower::lower_clif_block at ./cranelift/codegen/src/machinst/lower.rs:741:33 30: cranelift_codegen::machinst::lower::Lower::lower at ./cranelift/codegen/src/machinst/lower.rs:1045:17 31: cranelift_codegen::machinst::compile::compile at ./cranelift/codegen/src/machinst/compile.rs:40:9 32: cranelift_codegen::isa::x64::X64Backend::compile_vcode at ./cranelift/codegen/src/isa/x64/mod.rs:61:9 33: ::compile_function at ./cranelift/codegen/src/isa/x64/mod.rs:73:40 34: cranelift_codegen::context::Context::compile_stencil at ./cranelift/codegen/src/context.rs:146:9 35: cranelift_codegen::context::Context::compile at ./cranelift/codegen/src/context.rs:206:23 36: cranelift_codegen::context::Context::compile_and_emit at ./cranelift/codegen/src/context.rs:127:29 37: wasmtime_cranelift::compiler::compile_uncached at ./crates/cranelift/src/compiler.rs:654:25 38: wasmtime_cranelift::compiler::compile_maybe_cached at ./crates/cranelift/src/compiler.rs:646:5 39: wasmtime_cranelift::compiler::FunctionCompiler::finish_with_info at ./crates/cranelift/src/compiler.rs:993:13 40: wasmtime_cranelift::compiler::FunctionCompiler::finish at ./crates/cranelift/src/compiler.rs:981:28 41: ::compile_array_to_wasm_trampoline at ./crates/cranelift/src/compiler.rs:297:21 42: wasmtime::module::Module::compile_functions::{{closure}} at ./crates/wasmtime/src/module.rs:684:34 43: wasmtime::engine::Engine::run_maybe_parallel::{{closure}} at ./crates/wasmtime/src/engine.rs:267:26 44: core::ops::function::impls:: for &F>::call_mut at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/ops/function.rs:274:13 45: core::ops::function::impls:: for &mut F>::call_once at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/ops/function.rs:310:13 46: core::option::Option::map at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/option.rs:1091:29 47: as core::iter::traits::iterator::Iterator>::next at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/iter/adapters/map.rs:103:9 48: as core::iter::traits::iterator::Iterator>::next at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/iter/adapters/map.rs:103:9 49: as core::iter::traits::iterator::Iterator>::next at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/iter/adapters/take_while.rs:46:21 50: as core::iter::traits::iterator::Iterator>::next at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/iter/adapters/map.rs:103:9 51: alloc::vec::Vec::extend_desugared at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/alloc/src/vec/mod.rs:2824:35 52: as alloc::vec::spec_extend::SpecExtend>::spec_extend at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/alloc/src/vec/spec_extend.rs:17:9 53: as core::iter::traits::collect::Extend>::extend at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/alloc/src/vec/mod.rs:2798:9 54: as rayon::iter::plumbing::Folder>::consume_iter at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/iter/extend.rs:73:9 55: as rayon::iter::plumbing::Folder>>::consume_iter at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/iter/while_some.rs:139:21 56: as rayon::iter::plumbing::Folder>::consume_iter at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/iter/map.rs:248:21 57: as rayon::iter::plumbing::Folder>::consume_iter at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/iter/map.rs:248:21 58: rayon::iter::plumbing::Producer::fold_with at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/iter/plumbing/mod.rs:110:9 59: rayon::iter::plumbing::bridge_producer_consumer::helper at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/iter/plumbing/mod.rs:438:13 60: rayon::iter::plumbing::bridge_producer_consumer at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/iter/plumbing/mod.rs:397:12 61: as rayon::iter::plumbing::ProducerCallback>::callback at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/iter/plumbing/mod.rs:373:13 62: as rayon::iter::IndexedParallelIterator>::with_producer at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/vec.rs:147:13 63: as rayon::iter::IndexedParallelIterator>::with_producer at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/vec.rs:83:9 64: rayon::iter::plumbing::bridge at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/iter/plumbing/mod.rs:357:12 65: as rayon::iter::ParallelIterator>::drive_unindexed at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/vec.rs:58:9 66: as rayon::iter::ParallelIterator>::drive_unindexed at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/iter/map.rs:49:9 67: as rayon::iter::ParallelIterator>::drive_unindexed at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/iter/map.rs:49:9 68: as rayon::iter::ParallelIterator>::drive_unindexed at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/iter/while_some.rs:44:9 69: rayon::iter::extend:: for alloc::vec::Vec>::par_extend at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/iter/extend.rs:576:28 70: rayon::iter::from_par_iter::collect_extended at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/iter/from_par_iter.rs:17:5 71: rayon::iter::from_par_iter:: for alloc::vec::Vec>::from_par_iter at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/iter/from_par_iter.rs:30:9 72: rayon::iter::ParallelIterator::collect at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/iter/mod.rs:2046:9 73: rayon::result::> for core::result::Result>::from_par_iter at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/result.rs:121:26 74: rayon::iter::ParallelIterator::collect at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/iter/mod.rs:2046:9 75: wasmtime::engine::Engine::run_maybe_parallel at ./crates/wasmtime/src/engine.rs:265:20 76: wasmtime::module::Module::compile_functions at ./crates/wasmtime/src/module.rs:659:13 77: wasmtime::component::component::Component::build_artifacts::{{closure}} at ./crates/wasmtime/src/component/component.rs:202:13 78: wasmtime::engine::Engine::run_maybe_parallel::{{closure}} at ./crates/wasmtime/src/engine.rs:267:26 79: core::ops::function::impls:: for &F>::call_mut at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/ops/function.rs:274:13 80: core::ops::function::impls:: for &mut F>::call_once at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/ops/function.rs:310:13 81: core::option::Option::map at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/option.rs:1091:29 82: as core::iter::traits::iterator::Iterator>::next at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/iter/adapters/map.rs:103:9 83: as core::iter::traits::iterator::Iterator>::next at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/iter/adapters/map.rs:103:9 84: as core::iter::traits::iterator::Iterator>::next at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/iter/adapters/take_while.rs:46:21 85: as core::iter::traits::iterator::Iterator>::next at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/iter/adapters/map.rs:103:9 86: alloc::vec::Vec::extend_desugared at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/alloc/src/vec/mod.rs:2824:35 87: as alloc::vec::spec_extend::SpecExtend>::spec_extend at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/alloc/src/vec/spec_extend.rs:17:9 88: as core::iter::traits::collect::Extend>::extend at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/alloc/src/vec/mod.rs:2798:9 89: as rayon::iter::plumbing::Folder>::consume_iter at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/iter/extend.rs:73:9 90: as rayon::iter::plumbing::Folder>>::consume_iter at /home/klee/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.5.3/src/iter/while_some.rs:139:21 note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. thread '' panicked at 'called `Option::unwrap()` on a `None` value', cranelift/codegen/src/machinst/reg.rs:499:32 thread '' panicked at 'called `Option::unwrap()` on a `None` value', cranelift/codegen/src/machinst/reg.rs:499:32 failures: component_model::strings::roundtrip test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 955 filtered out; finished in 0.19s error: test failed, to rerun pass `--test all` ```

The function in question is:

pub fn next_fixed_nonallocatable(&mut self, preg: PReg) {
    let alloc = self.allocs.next();
    let alloc = alloc.map(|alloc| {
        Reg::from(
            alloc
                .as_reg()
                .expect("Should not have gotten a stack allocation"),
        )
    });

    assert_eq!(preg, alloc.unwrap().to_real_reg().unwrap().into());
}

where the unwrap in the assert is where the panic comes from. It seems that there are no more allocations left? However, that is weird since it seems to be in the middle of the function as the inst before should be the get_stack_pointer instruction from block4.

I'm not really familiar with how the pretty printing works in detail so maybe you have an idea why that's happening.

jameysharp commented 1 year ago

Thanks for the bug report! I don't know what the issue is, but I did find a simpler way to reproduce it:

RUST_LOG=trace cargo run -p cranelift-tools -- test cranelift/filetests/filetests/isa/x64/fp_sp_pc.clif

Another one that hits the same assert is cranelift/filetests/filetests/isa/x64/pinned-reg.clif.

I think aside from those two, all the other x64 filetests pass. So the fact that these deal with special registers might be significant.

Maybe @elliottt or @cfallin can figure out what's going on here.