Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Miri working on ARM again #2791

Closed
joshlf opened this issue Feb 16, 2023 · 18 comments · Fixed by #2798
Closed

Get Miri working on ARM again #2791

joshlf opened this issue Feb 16, 2023 · 18 comments · Fixed by #2798

Comments

@joshlf
Copy link

joshlf commented Feb 16, 2023

It looks like Miri is currently broken on ARM. @saethlin has provided basic mentoring instructions: #2791 (comment).

Based on this comment, it appears that the bug was introduced between nightly-2022-11-13 and nightly-2022-11-14.

Original contents

In this commit of zerocopy, cargo miri test fails with the following error (edited for brevity - see the full log here):

$ cargo +nightly-2023-02-14 miri test --package zerocopy --target arm-unknown-linux-gnueabi --all-features -- --skip ui
...
running 50 tests
error: unsupported operation: can't call foreign function `llvm.arm.hint` on OS `linux`
  --> /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/arm_shared/hints.rs:69:5
   |
69 |     hint(HINT_YIELD);
   |     ^^^^^^^^^^^^^^^^ can't call foreign function `llvm.arm.hint` on OS `linux`
   |
   = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
   = note: BACKTRACE:
   = note: inside `std::arch::arm::__yield` at /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/arm_shared/hints.rs:69:5: 69:21
   = note: inside `std::hint::spin_loop` at /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/hint.rs:204:22: 204:49
   = note: inside `std::sync::mpmc::utils::Backoff::spin_light` at /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sync/mpmc/utils.rs:114:13: 114:37
   = note: inside `std::sync::mpmc::list::Channel::<tests::test::event::CompletedTest>::start_send` at /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sync/mpmc/list.rs:250:21: 250:41
   = note: inside `std::sync::mpmc::list::Channel::<tests::test::event::CompletedTest>::send` at /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sync/mpmc/list.rs:402:17: 402:39
   = note: inside `std::sync::mpmc::Sender::<tests::test::event::CompletedTest>::send` at /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sync/mpmc/mod.rs:128:41: 128:61
   = note: inside `std::sync::mpsc::Sender::<tests::test::event::CompletedTest>::send` at /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sync/mpsc/mod.rs:614:9: 614:27
   = note: inside `tests::test::run_test_in_process` at /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:693:5: 693:29
   = note: inside closure at /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:573:39: 5[81](https://github.com/google/zerocopy/actions/runs/4197219373/jobs/7279259385#step:11:82):14
   = note: inside closure at /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:600:37: 600:79
   = note: inside `std::sys_common::backtrace::__rust_begin_short_backtrace::<[closure@tests::test::run_test::run_test_inner::{closure#1}], ()>` at /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:121:18: 121:21
   = note: inside closure at /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:558:17: 558:78
   = note: inside `<std::panic::AssertUnwindSafe<[closure@std::thread::Builder::spawn_unchecked_<'_, '_, [closure@tests::test::run_test::run_test_inner::{closure#1}], ()>::{closure#1}::{closure#0}]> as std::ops::FnOnce<()>>::call_once` at /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:271:9: 271:19
   = note: inside `std::panicking::r#try::do_call::<std::panic::AssertUnwindSafe<[closure@std::thread::Builder::spawn_unchecked_<'_, '_, [closure@tests::test::run_test::run_test_inner::{closure#1}], ()>::{closure#1}::{closure#0}]>, ()>` at /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:4[83](https://github.com/google/zerocopy/actions/runs/4197219373/jobs/7279259385#step:11:84):40: 483:43
   = note: inside `std::panicking::r#try::<(), std::panic::AssertUnwindSafe<[closure@std::thread::Builder::spawn_unchecked_<'_, '_, [closure@tests::test::run_test::run_test_inner::{closure#1}], ()>::{closure#1}::{closure#0}]>>` at /home/runner/.rustup/toolchains/nightly-2023-02-14-x[86](https://github.com/google/zerocopy/actions/runs/4197219373/jobs/7279259385#step:11:87)_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:447:19: 447:81
   = note: inside `std::panic::catch_unwind::<std::panic::AssertUnwindSafe<[closure@std::thread::Builder::spawn_unchecked_<'_, '_, [closure@tests::test::run_test::run_test_inner::{closure#1}], ()>::{closure#1}::{closure#0}]>, ()>` at /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:140:14: 140:33
   = note: inside closure at /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:557:30: 559:16
   = note: inside `<[closure@std::thread::Builder::spawn_unchecked_<'_, '_, [closure@tests::test::run_test::run_test_inner::{closure#1}], ()>::{closure#1}] as std::ops::FnOnce<()>>::call_once - shim(vtable)` at /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5: 250:71
   = note: inside `<std::boxed::Box<dyn std::ops::FnOnce()> as std::ops::FnOnce<()>>::call_once` at /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:19[88](https://github.com/google/zerocopy/actions/runs/4197219373/jobs/7279259385#step:11:89):9: 1[98](https://github.com/google/zerocopy/actions/runs/4197219373/jobs/7279259385#step:11:99)8:52
   = note: inside `<std::boxed::Box<std::boxed::Box<dyn std::ops::FnOnce()>> as std::ops::FnOnce<()>>::call_once` at /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1988:9: 1988:52
   = note: inside `std::sys::unix::thread::Thread::new::thread_start` at /home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/thread.rs:[108](https://github.com/google/zerocopy/actions/runs/4197219373/jobs/7279259385#step:11:109):17: 108:64

error: aborting due to previous error

error: test failed, to rerun pass `-p zerocopy --lib`

Caused by:
  process didn't exit successfully: `/home/runner/.rustup/toolchains/nightly-2023-02-14-x86_64-unknown-linux-gnu/bin/cargo-miri runner /home/runner/work/zerocopy/zerocopy/target/miri/arm-unknown-linux-gnueabi/debug/deps/zerocopy-51d03519d8186c51 --skip ui` (exit status: 1)
test alloc_support::tests::test_extend_vec_zeroed ... 
Error: Process completed with exit code 1.
@saethlin
Copy link
Member

Ouch, sounds like we don't fully support the new standard library channels anymore. That's bad.

@oli-obk
Copy link
Contributor

oli-obk commented Feb 16, 2023

Why is this going through an arm path on x86_64-unknown-linux-gnu?

@bjorn3
Copy link
Member

bjorn3 commented Feb 16, 2023

Because OP used --target to run on the arm target.

@oli-obk
Copy link
Contributor

oli-obk commented Feb 16, 2023

oh right, I just looked at the path in the error.

Yea, we don't test platforms other than x86_64/i686 x linux/windows/mac. Though with the usage that arm is getting in practice, we may want to start testing that, too

@joshlf
Copy link
Author

joshlf commented Feb 16, 2023

Any guesses as to when this might have regressed? We pin to a particular nightly toolchain in our CI, so if there's an older non-buggy Miri, we could pin to that to unblock ourselves.

@oli-obk
Copy link
Contributor

oli-obk commented Feb 16, 2023

I don't know if we ever supported channel on arm, is this the first time you're running miri on those tests?

@joshlf
Copy link
Author

joshlf commented Feb 16, 2023

Nope, been running them for a few months. The commit in question just updates what pinned toolchain versions we use in CI (before this commit, it was 1.61.0, 1.64.0, and nightly-2022-10-17).

@oli-obk
Copy link
Contributor

oli-obk commented Feb 16, 2023

yea just saw that. I guess without us testing against arm, such regressions may randomly happen to you again in the future even if we fix this one. I don't know whether there will be more problems if we just turn on tests for an arm target, but we can try.

@joshlf
Copy link
Author

joshlf commented Feb 16, 2023

If it's not too much work to test on arm, that'd be great for us! But of course asking for free labor is always easy 😛

@saethlin
Copy link
Member

It's not a huge amount of work. This might even be something for a new contributor to do.

  • Clone the repo
  • Run ./miri toolchain
  • Run MIRI_TEST_TARGET=arm-unknown-linux-gnueabi ./miri test
  • Figure out how to get that to pass, sounds like the situation in this issue in particular just needs a no-op shim but I also tried this and I see a type mismatch which is confusing... maybe someone who knows the target is less confused by it.
  • Add this target to the bottom of ci.sh

@RalfJung
Copy link
Member

If that all works, the target should also be added in https://github.com/rust-lang/miri#supported-targets.

@joshlf joshlf changed the title Miri fails with error: "can't call foreign function llvm.arm.hint on OS linux" Get Miri working on ARM again Feb 17, 2023
@joshlf
Copy link
Author

joshlf commented Feb 17, 2023

I posted this issue to This Week in Rust's Call for Participation. Hopefully we'll get someone to take a stab at it!

@joshlf
Copy link
Author

joshlf commented Feb 23, 2023

I wasn't able to get git bisect on this repository, but I was able to use zerocopy's CI to bisect on nightly releases, and found that the bug was introduced between nightly-2022-11-13 and nightly-2022-11-14 (see here for more details). Hopefully that helps narrow things down!

@RalfJung
Copy link
Member

Do you have git commit SHAs corresponding to these nightlies?

@LevitatingLion
Copy link
Contributor

I saw your Call for Participation on This Week in Rust, would love to take a stab at this! I've never looked at Miri's code before, but this seems like a good opportunity to start.

@joshlf
Copy link
Author

joshlf commented Feb 23, 2023

@RalfJung I'm not sure where that information lives; I was hoping someone on this thread might know.

@LevitatingLion Thanks!!

@RalfJung
Copy link
Member

rust --version should show the commit ID. Usually this is somewhere in the CI logs, but I guess it depend on the setup.

@joshlf
Copy link
Author

joshlf commented Feb 23, 2023

Ah gotcha. Here's the output:

$ rustc +nightly-2022-11-13 --version
rustc 1.67.0-nightly (6284998a2 2022-11-12)
$ rustc +nightly-2022-11-14 --version
rustc 1.67.0-nightly (e631891f7 2022-11-13)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants