Stream: git-wasmtime

Topic: wasmtime / issue #3581 cranelift x64: Panic lowering `shu...


view this post on Zulip Wasmtime GitHub notifications bot (Dec 01 2021 at 21:47):

alexcrichton labeled issue #3581:

I ran into an odd issue today where https://github.com/bytecodealliance/wasmtime/pull/3579 failed on CI, but it didn't change anything to the point that nothing in theory should have failed, much less a clif codegen test. I'm going to copy the failure here because I'm about to rerun CI at which point I suspect the logs will get overwritten:

<details>

...
thread 'worker #0' panicked at 'shuffle mask values must be between 0 and 31', cranelift/codegen/src/isa/x64/lower.rs:5519:21
stack backtrace:
   0: std::panicking::begin_panic
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:543:12
   1: cranelift_codegen::isa::x64::lower::lower_insn_to_regs
             at ./codegen/src/isa/x64/lower.rs:5519:21
   2: cranelift_codegen::isa::x64::lower::<impl cranelift_codegen::machinst::lower::LowerBackend for cranelift_codegen::isa::x64::X64Backend>::lower
             at ./codegen/src/isa/x64/lower.rs:6115:9
   3: cranelift_codegen::machinst::lower::Lower<I>::lower_clif_block
             at ./codegen/src/machinst/lower.rs:750:17
   4: cranelift_codegen::machinst::lower::Lower<I>::lower
             at ./codegen/src/machinst/lower.rs:991:17
   5: cranelift_codegen::machinst::compile::compile
             at ./codegen/src/machinst/compile.rs:29:9
   6: cranelift_codegen::isa::x64::X64Backend::compile_vcode
             at ./codegen/src/isa/x64/mod.rs:53:9
   7: <cranelift_codegen::isa::x64::X64Backend as cranelift_codegen::machinst::MachBackend>::compile_function
             at ./codegen/src/isa/x64/mod.rs:64:21
   8: cranelift_codegen::context::Context::compile
             at ./codegen/src/context.rs:172:22
   9: cranelift_filetests::function_runner::compile
             at ./filetests/src/function_runner.rs:247:21
  10: cranelift_filetests::function_runner::SingleFunctionCompiler::compile
             at ./filetests/src/function_runner.rs:76:25
  11: <cranelift_filetests::test_run::TestRun as cranelift_filetests::subtest::SubTest>::run
             at ./filetests/src/test_run.rs:64:35
  12: cranelift_filetests::runone::run_one_test
             at ./filetests/src/runone.rs:187:5
  13: cranelift_filetests::runone::run
             at ./filetests/src/runone.rs:132:9
  14: cranelift_filetests::concurrent::worker_thread::{{closure}}::{{closure}}
             at ./filetests/src/concurrent.rs:150:46
  15: std::panicking::try::do_call
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:403:40
  16: __rust_try
  17: std::panicking::try
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:367:19
  18: std::panic::catch_unwind
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panic.rs:129:14
  19: cranelift_filetests::concurrent::worker_thread::{{closure}}
             at ./filetests/src/concurrent.rs:150:30
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
...
FAIL filetests/filetests/runtests/simd-shuffle.clif: panicked in worker #0: shuffle mask values must be between 0 and 31
...
342 tests
thread 'filetests' panicked at 'test harness: 1 failure', cranelift/tests/filetests.rs:5:10
stack backtrace:
   0: rust_begin_unwind
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/panicking.rs:101:14
   2: core::result::unwrap_failed
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/result.rs:1617:5
   3: core::result::Result<T,E>::expect
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/result.rs:1259:23
   4: filetests::filetests
             at ./tests/filetests.rs:4:5
   5: filetests::filetests::{{closure}}
             at ./tests/filetests.rs:2:1
   6: core::ops::function::FnOnce::call_once
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/ops/function.rs:227:5
   7: core::ops::function::FnOnce::call_once
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    filetests

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 9.75s
...

</details>

or, effectively:

...
thread 'worker #0' panicked at 'shuffle mask values must be between 0 and 31', cranelift/codegen/src/isa/x64/lower.rs:5519:21
...
FAIL filetests/filetests/runtests/simd-shuffle.clif: panicked in worker #0: shuffle mask values must be between 0 and 31
...

This looks like a "spurious" error in that it doesn't reproduce on other PRs on CI. The code in question, though:

https://github.com/bytecodealliance/wasmtime/blob/ccf31a33b80517dc9c30811c4c20c121db0fbdd3/cranelift/codegen/src/isa/x64/lower.rs#L5518-L5522

is specifically gated for avx512 features, and cranelift filetests do indeed use cranelift-native so my guess as to why this only showed up on my PR is that it just-so-happened to run on a machine with avx512 features enabled on its CPU. Assuming that's enabled I think it explains why this panics.

This leads me to the actual issue here, the clif test in question specifically uses out-of-bounds indices for a shuffle argument:

function %shuffle_i8x16(i8x16, i8x16) -> i8x16 {
block0(v0: i8x16, v1: i8x16):
    v2 = shuffle v0, v1, [3 0 31 26 100 6 12 11 23 13 24 4 2 15 17 5]
    return v2
}

which looks like what's tripping the assert in the avx512 branch I think. I can reproduce this myself with a clif test that looks like:

test compile
set enable_simd
target x86_64 has_avx512vl has_avx512vbmi

function %shuffle_i8x16(i8x16, i8x16) -> i8x16 {
block0(v0: i8x16, v1: i8x16):
    v2 = shuffle v0, v1, [3 0 31 26 100 6 12 11 23 13 24 4 2 15 17 5]
    return v2
}

this will fail with the same panic in clif-util test foo.clif

cc @abrown @jlb6740

view this post on Zulip Wasmtime GitHub notifications bot (Dec 01 2021 at 21:47):

alexcrichton opened issue #3581:

I ran into an odd issue today where https://github.com/bytecodealliance/wasmtime/pull/3579 failed on CI, but it didn't change anything to the point that nothing in theory should have failed, much less a clif codegen test. I'm going to copy the failure here because I'm about to rerun CI at which point I suspect the logs will get overwritten:

<details>

...
thread 'worker #0' panicked at 'shuffle mask values must be between 0 and 31', cranelift/codegen/src/isa/x64/lower.rs:5519:21
stack backtrace:
   0: std::panicking::begin_panic
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:543:12
   1: cranelift_codegen::isa::x64::lower::lower_insn_to_regs
             at ./codegen/src/isa/x64/lower.rs:5519:21
   2: cranelift_codegen::isa::x64::lower::<impl cranelift_codegen::machinst::lower::LowerBackend for cranelift_codegen::isa::x64::X64Backend>::lower
             at ./codegen/src/isa/x64/lower.rs:6115:9
   3: cranelift_codegen::machinst::lower::Lower<I>::lower_clif_block
             at ./codegen/src/machinst/lower.rs:750:17
   4: cranelift_codegen::machinst::lower::Lower<I>::lower
             at ./codegen/src/machinst/lower.rs:991:17
   5: cranelift_codegen::machinst::compile::compile
             at ./codegen/src/machinst/compile.rs:29:9
   6: cranelift_codegen::isa::x64::X64Backend::compile_vcode
             at ./codegen/src/isa/x64/mod.rs:53:9
   7: <cranelift_codegen::isa::x64::X64Backend as cranelift_codegen::machinst::MachBackend>::compile_function
             at ./codegen/src/isa/x64/mod.rs:64:21
   8: cranelift_codegen::context::Context::compile
             at ./codegen/src/context.rs:172:22
   9: cranelift_filetests::function_runner::compile
             at ./filetests/src/function_runner.rs:247:21
  10: cranelift_filetests::function_runner::SingleFunctionCompiler::compile
             at ./filetests/src/function_runner.rs:76:25
  11: <cranelift_filetests::test_run::TestRun as cranelift_filetests::subtest::SubTest>::run
             at ./filetests/src/test_run.rs:64:35
  12: cranelift_filetests::runone::run_one_test
             at ./filetests/src/runone.rs:187:5
  13: cranelift_filetests::runone::run
             at ./filetests/src/runone.rs:132:9
  14: cranelift_filetests::concurrent::worker_thread::{{closure}}::{{closure}}
             at ./filetests/src/concurrent.rs:150:46
  15: std::panicking::try::do_call
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:403:40
  16: __rust_try
  17: std::panicking::try
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:367:19
  18: std::panic::catch_unwind
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panic.rs:129:14
  19: cranelift_filetests::concurrent::worker_thread::{{closure}}
             at ./filetests/src/concurrent.rs:150:30
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
...
FAIL filetests/filetests/runtests/simd-shuffle.clif: panicked in worker #0: shuffle mask values must be between 0 and 31
...
342 tests
thread 'filetests' panicked at 'test harness: 1 failure', cranelift/tests/filetests.rs:5:10
stack backtrace:
   0: rust_begin_unwind
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/panicking.rs:101:14
   2: core::result::unwrap_failed
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/result.rs:1617:5
   3: core::result::Result<T,E>::expect
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/result.rs:1259:23
   4: filetests::filetests
             at ./tests/filetests.rs:4:5
   5: filetests::filetests::{{closure}}
             at ./tests/filetests.rs:2:1
   6: core::ops::function::FnOnce::call_once
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/ops/function.rs:227:5
   7: core::ops::function::FnOnce::call_once
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    filetests

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 9.75s
...

</details>

or, effectively:

...
thread 'worker #0' panicked at 'shuffle mask values must be between 0 and 31', cranelift/codegen/src/isa/x64/lower.rs:5519:21
...
FAIL filetests/filetests/runtests/simd-shuffle.clif: panicked in worker #0: shuffle mask values must be between 0 and 31
...

This looks like a "spurious" error in that it doesn't reproduce on other PRs on CI. The code in question, though:

https://github.com/bytecodealliance/wasmtime/blob/ccf31a33b80517dc9c30811c4c20c121db0fbdd3/cranelift/codegen/src/isa/x64/lower.rs#L5518-L5522

is specifically gated for avx512 features, and cranelift filetests do indeed use cranelift-native so my guess as to why this only showed up on my PR is that it just-so-happened to run on a machine with avx512 features enabled on its CPU. Assuming that's enabled I think it explains why this panics.

This leads me to the actual issue here, the clif test in question specifically uses out-of-bounds indices for a shuffle argument:

function %shuffle_i8x16(i8x16, i8x16) -> i8x16 {
block0(v0: i8x16, v1: i8x16):
    v2 = shuffle v0, v1, [3 0 31 26 100 6 12 11 23 13 24 4 2 15 17 5]
    return v2
}

which looks like what's tripping the assert in the avx512 branch I think. I can reproduce this myself with a clif test that looks like:

test compile
set enable_simd
target x86_64 has_avx512vl has_avx512vbmi

function %shuffle_i8x16(i8x16, i8x16) -> i8x16 {
block0(v0: i8x16, v1: i8x16):
    v2 = shuffle v0, v1, [3 0 31 26 100 6 12 11 23 13 24 4 2 15 17 5]
    return v2
}

this will fail with the same panic in clif-util test foo.clif

cc @abrown @jlb6740

view this post on Zulip Wasmtime GitHub notifications bot (Dec 01 2021 at 21:48):

alexcrichton labeled issue #3581:

I ran into an odd issue today where https://github.com/bytecodealliance/wasmtime/pull/3579 failed on CI, but it didn't change anything to the point that nothing in theory should have failed, much less a clif codegen test. I'm going to copy the failure here because I'm about to rerun CI at which point I suspect the logs will get overwritten:

<details>

...
thread 'worker #0' panicked at 'shuffle mask values must be between 0 and 31', cranelift/codegen/src/isa/x64/lower.rs:5519:21
stack backtrace:
   0: std::panicking::begin_panic
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:543:12
   1: cranelift_codegen::isa::x64::lower::lower_insn_to_regs
             at ./codegen/src/isa/x64/lower.rs:5519:21
   2: cranelift_codegen::isa::x64::lower::<impl cranelift_codegen::machinst::lower::LowerBackend for cranelift_codegen::isa::x64::X64Backend>::lower
             at ./codegen/src/isa/x64/lower.rs:6115:9
   3: cranelift_codegen::machinst::lower::Lower<I>::lower_clif_block
             at ./codegen/src/machinst/lower.rs:750:17
   4: cranelift_codegen::machinst::lower::Lower<I>::lower
             at ./codegen/src/machinst/lower.rs:991:17
   5: cranelift_codegen::machinst::compile::compile
             at ./codegen/src/machinst/compile.rs:29:9
   6: cranelift_codegen::isa::x64::X64Backend::compile_vcode
             at ./codegen/src/isa/x64/mod.rs:53:9
   7: <cranelift_codegen::isa::x64::X64Backend as cranelift_codegen::machinst::MachBackend>::compile_function
             at ./codegen/src/isa/x64/mod.rs:64:21
   8: cranelift_codegen::context::Context::compile
             at ./codegen/src/context.rs:172:22
   9: cranelift_filetests::function_runner::compile
             at ./filetests/src/function_runner.rs:247:21
  10: cranelift_filetests::function_runner::SingleFunctionCompiler::compile
             at ./filetests/src/function_runner.rs:76:25
  11: <cranelift_filetests::test_run::TestRun as cranelift_filetests::subtest::SubTest>::run
             at ./filetests/src/test_run.rs:64:35
  12: cranelift_filetests::runone::run_one_test
             at ./filetests/src/runone.rs:187:5
  13: cranelift_filetests::runone::run
             at ./filetests/src/runone.rs:132:9
  14: cranelift_filetests::concurrent::worker_thread::{{closure}}::{{closure}}
             at ./filetests/src/concurrent.rs:150:46
  15: std::panicking::try::do_call
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:403:40
  16: __rust_try
  17: std::panicking::try
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:367:19
  18: std::panic::catch_unwind
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panic.rs:129:14
  19: cranelift_filetests::concurrent::worker_thread::{{closure}}
             at ./filetests/src/concurrent.rs:150:30
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
...
FAIL filetests/filetests/runtests/simd-shuffle.clif: panicked in worker #0: shuffle mask values must be between 0 and 31
...
342 tests
thread 'filetests' panicked at 'test harness: 1 failure', cranelift/tests/filetests.rs:5:10
stack backtrace:
   0: rust_begin_unwind
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/panicking.rs:101:14
   2: core::result::unwrap_failed
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/result.rs:1617:5
   3: core::result::Result<T,E>::expect
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/result.rs:1259:23
   4: filetests::filetests
             at ./tests/filetests.rs:4:5
   5: filetests::filetests::{{closure}}
             at ./tests/filetests.rs:2:1
   6: core::ops::function::FnOnce::call_once
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/ops/function.rs:227:5
   7: core::ops::function::FnOnce::call_once
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    filetests

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 9.75s
...

</details>

or, effectively:

...
thread 'worker #0' panicked at 'shuffle mask values must be between 0 and 31', cranelift/codegen/src/isa/x64/lower.rs:5519:21
...
FAIL filetests/filetests/runtests/simd-shuffle.clif: panicked in worker #0: shuffle mask values must be between 0 and 31
...

This looks like a "spurious" error in that it doesn't reproduce on other PRs on CI. The code in question, though:

https://github.com/bytecodealliance/wasmtime/blob/ccf31a33b80517dc9c30811c4c20c121db0fbdd3/cranelift/codegen/src/isa/x64/lower.rs#L5518-L5522

is specifically gated for avx512 features, and cranelift filetests do indeed use cranelift-native so my guess as to why this only showed up on my PR is that it just-so-happened to run on a machine with avx512 features enabled on its CPU. Assuming that's enabled I think it explains why this panics.

This leads me to the actual issue here, the clif test in question specifically uses out-of-bounds indices for a shuffle argument:

function %shuffle_i8x16(i8x16, i8x16) -> i8x16 {
block0(v0: i8x16, v1: i8x16):
    v2 = shuffle v0, v1, [3 0 31 26 100 6 12 11 23 13 24 4 2 15 17 5]
    return v2
}

which looks like what's tripping the assert in the avx512 branch I think. I can reproduce this myself with a clif test that looks like:

test compile
set enable_simd
target x86_64 has_avx512vl has_avx512vbmi

function %shuffle_i8x16(i8x16, i8x16) -> i8x16 {
block0(v0: i8x16, v1: i8x16):
    v2 = shuffle v0, v1, [3 0 31 26 100 6 12 11 23 13 24 4 2 15 17 5]
    return v2
}

this will fail with the same panic in clif-util test foo.clif

cc @abrown @jlb6740

view this post on Zulip Wasmtime GitHub notifications bot (Dec 01 2021 at 23:52):

abrown commented on issue #3581:

Looks like that assertion was written under the assumption that the verifier would remove invalid lane indices: https://github.com/bytecodealliance/wasmtime/blob/main/cranelift/codegen/src/verifier/mod.rs#L56-L57.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 01 2021 at 23:52):

abrown edited a comment on issue #3581:

Looks like that assertion was written under the assumption that the verifier would remove invalid lane indices:

https://github.com/bytecodealliance/wasmtime/blob/main/cranelift/codegen/src/verifier/mod.rs#L56-L57.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 01 2021 at 23:52):

abrown edited a comment on issue #3581:

Looks like that assertion was written under the assumption that the verifier would remove invalid lane indices:

https://github.com/bytecodealliance/wasmtime/blob/main/cranelift/codegen/src/verifier/mod.rs#L56-L57

view this post on Zulip Wasmtime GitHub notifications bot (Dec 01 2021 at 23:53):

abrown edited a comment on issue #3581:

Looks like that assertion was written under the assumption that the verifier would remove invalid lane indices:

https://github.com/bytecodealliance/wasmtime/blob/868c40cde22c33414cc4d9fabe184c5cd364a0db/cranelift/codegen/src/verifier/mod.rs#L56-L57

view this post on Zulip Wasmtime GitHub notifications bot (Dec 02 2021 at 23:06):

fitzgen commented on issue #3581:

That is something that the verifier checks/asserts, not something that it will make true for you. The verifier is only used in ~debug builds. (If you already know this, apologies, it isn't clear to me based on your comment.)

view this post on Zulip Wasmtime GitHub notifications bot (Dec 03 2021 at 00:22):

abrown commented on issue #3581:

Yup. I may have not been aware of that when that code was originally written. What is worse is that I don't think the verifier actually does that check anyways--or at least not that I can find--so there also might be some documentation that needs to be changed here.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 16 2021 at 18:36):

abrown closed issue #3581:

I ran into an odd issue today where https://github.com/bytecodealliance/wasmtime/pull/3579 failed on CI, but it didn't change anything to the point that nothing in theory should have failed, much less a clif codegen test. I'm going to copy the failure here because I'm about to rerun CI at which point I suspect the logs will get overwritten:

<details>

...
thread 'worker #0' panicked at 'shuffle mask values must be between 0 and 31', cranelift/codegen/src/isa/x64/lower.rs:5519:21
stack backtrace:
   0: std::panicking::begin_panic
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:543:12
   1: cranelift_codegen::isa::x64::lower::lower_insn_to_regs
             at ./codegen/src/isa/x64/lower.rs:5519:21
   2: cranelift_codegen::isa::x64::lower::<impl cranelift_codegen::machinst::lower::LowerBackend for cranelift_codegen::isa::x64::X64Backend>::lower
             at ./codegen/src/isa/x64/lower.rs:6115:9
   3: cranelift_codegen::machinst::lower::Lower<I>::lower_clif_block
             at ./codegen/src/machinst/lower.rs:750:17
   4: cranelift_codegen::machinst::lower::Lower<I>::lower
             at ./codegen/src/machinst/lower.rs:991:17
   5: cranelift_codegen::machinst::compile::compile
             at ./codegen/src/machinst/compile.rs:29:9
   6: cranelift_codegen::isa::x64::X64Backend::compile_vcode
             at ./codegen/src/isa/x64/mod.rs:53:9
   7: <cranelift_codegen::isa::x64::X64Backend as cranelift_codegen::machinst::MachBackend>::compile_function
             at ./codegen/src/isa/x64/mod.rs:64:21
   8: cranelift_codegen::context::Context::compile
             at ./codegen/src/context.rs:172:22
   9: cranelift_filetests::function_runner::compile
             at ./filetests/src/function_runner.rs:247:21
  10: cranelift_filetests::function_runner::SingleFunctionCompiler::compile
             at ./filetests/src/function_runner.rs:76:25
  11: <cranelift_filetests::test_run::TestRun as cranelift_filetests::subtest::SubTest>::run
             at ./filetests/src/test_run.rs:64:35
  12: cranelift_filetests::runone::run_one_test
             at ./filetests/src/runone.rs:187:5
  13: cranelift_filetests::runone::run
             at ./filetests/src/runone.rs:132:9
  14: cranelift_filetests::concurrent::worker_thread::{{closure}}::{{closure}}
             at ./filetests/src/concurrent.rs:150:46
  15: std::panicking::try::do_call
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:403:40
  16: __rust_try
  17: std::panicking::try
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:367:19
  18: std::panic::catch_unwind
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panic.rs:129:14
  19: cranelift_filetests::concurrent::worker_thread::{{closure}}
             at ./filetests/src/concurrent.rs:150:30
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
...
FAIL filetests/filetests/runtests/simd-shuffle.clif: panicked in worker #0: shuffle mask values must be between 0 and 31
...
342 tests
thread 'filetests' panicked at 'test harness: 1 failure', cranelift/tests/filetests.rs:5:10
stack backtrace:
   0: rust_begin_unwind
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/panicking.rs:101:14
   2: core::result::unwrap_failed
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/result.rs:1617:5
   3: core::result::Result<T,E>::expect
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/result.rs:1259:23
   4: filetests::filetests
             at ./tests/filetests.rs:4:5
   5: filetests::filetests::{{closure}}
             at ./tests/filetests.rs:2:1
   6: core::ops::function::FnOnce::call_once
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/ops/function.rs:227:5
   7: core::ops::function::FnOnce::call_once
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    filetests

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 9.75s
...

</details>

or, effectively:

...
thread 'worker #0' panicked at 'shuffle mask values must be between 0 and 31', cranelift/codegen/src/isa/x64/lower.rs:5519:21
...
FAIL filetests/filetests/runtests/simd-shuffle.clif: panicked in worker #0: shuffle mask values must be between 0 and 31
...

This looks like a "spurious" error in that it doesn't reproduce on other PRs on CI. The code in question, though:

https://github.com/bytecodealliance/wasmtime/blob/ccf31a33b80517dc9c30811c4c20c121db0fbdd3/cranelift/codegen/src/isa/x64/lower.rs#L5518-L5522

is specifically gated for avx512 features, and cranelift filetests do indeed use cranelift-native so my guess as to why this only showed up on my PR is that it just-so-happened to run on a machine with avx512 features enabled on its CPU. Assuming that's enabled I think it explains why this panics.

This leads me to the actual issue here, the clif test in question specifically uses out-of-bounds indices for a shuffle argument:

function %shuffle_i8x16(i8x16, i8x16) -> i8x16 {
block0(v0: i8x16, v1: i8x16):
    v2 = shuffle v0, v1, [3 0 31 26 100 6 12 11 23 13 24 4 2 15 17 5]
    return v2
}

which looks like what's tripping the assert in the avx512 branch I think. I can reproduce this myself with a clif test that looks like:

test compile
set enable_simd
target x86_64 has_avx512vl has_avx512vbmi

function %shuffle_i8x16(i8x16, i8x16) -> i8x16 {
block0(v0: i8x16, v1: i8x16):
    v2 = shuffle v0, v1, [3 0 31 26 100 6 12 11 23 13 24 4 2 15 17 5]
    return v2
}

this will fail with the same panic in clif-util test foo.clif

cc @abrown @jlb6740


Last updated: Nov 22 2024 at 16:03 UTC