Stream: git-wasmtime

Topic: wasmtime / issue #6333 Cranelift: wasmtime tests crash wh...


view this post on Zulip Wasmtime GitHub notifications bot (May 02 2023 at 23:30):

T0b1-iOS edited issue #6333:

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:

<details>
<summary>Last bit of the log output</summary>

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<cranelift_codegen::ir::entities::Value> } }) 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<cranelift_codegen::ir::entities::Value> } }
[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<cranelift_codegen::ir::entities::Value> } }, BlockCall { values: EntityList { index: 85, unused: PhantomData<cranelift_codegen::ir::entities::Value> } }] }) 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<cranelift_codegen::ir::entities::Value> }, 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<cranelift_codegen::ir::entities::Value> }, 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 '<unnamed>' 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 '<unnamed>' 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<T>::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::<impl cranelift_codegen::machinst::reg::PrettyPrint for cranelift_codegen::isa::x64::lower::isle::generated_code::MInst>::pretty_print
             at ./cranelift/codegen/src/isa/x64/inst/mod.rs:1421:17
   6: cranelift_codegen::isa::x64::inst::<impl cranelift_codegen::machinst::MachInstEmit for cranelift_codegen::isa::x64::lower::isle::generated_code::MInst>::pretty_print_inst
             at ./cranelift/codegen/src/isa/x64/inst/mod.rs:2639:9
   7: cranelift_codegen::isa::x64::inst::<impl core::fmt::Debug for cranelift_codegen::isa::x64::lower::isle::generated_code::MInst>::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: <core::fmt::Arguments as core::fmt::Display>::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/kl
[message truncated]

view this post on Zulip Wasmtime GitHub notifications bot (May 03 2023 at 00:04):

jameysharp commented on issue #6333:

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.

view this post on Zulip Wasmtime GitHub notifications bot (May 05 2023 at 00:46):

cfallin closed issue #6333:

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:

<details>
<summary>Last bit of the log output</summary>

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<cranelift_codegen::ir::entities::Value> } }) 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<cranelift_codegen::ir::entities::Value> } }
[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<cranelift_codegen::ir::entities::Value> } }, BlockCall { values: EntityList { index: 85, unused: PhantomData<cranelift_codegen::ir::entities::Value> } }] }) 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<cranelift_codegen::ir::entities::Value> }, 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<cranelift_codegen::ir::entities::Value> }, 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 '<unnamed>' 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 '<unnamed>' 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<T>::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::<impl cranelift_codegen::machinst::reg::PrettyPrint for cranelift_codegen::isa::x64::lower::isle::generated_code::MInst>::pretty_print
             at ./cranelift/codegen/src/isa/x64/inst/mod.rs:1421:17
   6: cranelift_codegen::isa::x64::inst::<impl cranelift_codegen::machinst::MachInstEmit for cranelift_codegen::isa::x64::lower::isle::generated_code::MInst>::pretty_print_inst
             at ./cranelift/codegen/src/isa/x64/inst/mod.rs:2639:9
   7: cranelift_codegen::isa::x64::inst::<impl core::fmt::Debug for cranelift_codegen::isa::x64::lower::isle::generated_code::MInst>::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: <core::fmt::Arguments as core::fmt::Display>::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/kle
[message truncated]


Last updated: Nov 22 2024 at 16:03 UTC