rust-lang / miri

An interpreter for Rust's mid-level intermediate representation
Apache License 2.0
4.65k stars 348 forks source link

Miri does not support `Command` #3374

Open Da5hes opened 8 months ago

Da5hes commented 8 months ago

while trying miri on my repo i encountered the following error: can't call foreign function gnu_get_libc_version on OS linux

Details: ``` running 23 tests test core::reconciler::replica::tests::test_disown_missing_owners ... error: unsupported operation: can't call foreign function `gnu_get_libc_version` on OS `linux` --> /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/pal/unix/os.rs:766:48 | 766 | let version_cstr = unsafe { CStr::from_ptr(gnu_get_libc_version()) }; | ^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function `gnu_get_libc_version` 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::sys::pal::unix::os::glibc_version` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/pal/unix/os.rs:766:48: 766:70 = note: inside `std::sys::pal::unix::process::process_inner::::posix_spawn` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/pal/unix/process/process_unix.rs:475:36: 475:60 = note: inside `std::sys::pal::unix::process::process_inner::::spawn` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/pal/unix/process/process_unix.rs:89:28: 89:68 = note: inside `std::process::Command::status` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/process.rs:1002:9: 1003:46 = note: inside `::configure` at ****/deployer/src/infra/mod.rs:250:34: 253:34 = note: inside `composer::composer::Builder::configure::` at ****/utils/dependencies/composer/src/composer.rs:583:9: 583:28 = note: inside `deployer_cluster::ClusterBuilder::build_prepare` at ****/utils/deployer-cluster/src/lib.rs:690:24: 692:43 = note: inside closure at ****/utils/deployer-cluster/src/lib.rs:677:38: 677:58 note: inside closure --> control-plane/agents/core/src/core/reconciler/replica/tests.rs:25:10 | 25 | .await | ^^^^^ = note: inside `> as futures::Future>::poll` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/future.rs:124:9: 124:61 = note: inside `>> as futures::Future>::poll` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/future.rs:124:9: 124:61 = note: inside closure at ***/tokio-1.36.0/src/runtime/scheduler/current_thread/mod.rs:659:57: 659:86 = note: inside `tokio::runtime::coop::with_budget::, {closure@tokio::runtime::scheduler::current_thread::CoreGuard<'_>::block_on>>>::{closure#0}::{closure#0}::{closure#0}}>` at ***/tokio-1.36.0/src/runtime/coop.rs:107:5: 107:8 = note: inside `tokio::runtime::coop::budget::, {closure@tokio::runtime::scheduler::current_thread::CoreGuard<'_>::block_on>>>::{closure#0}::{closure#0}::{closure#0}}>` at ***/tokio-1.36.0/src/runtime/coop.rs:73:5: 73:38 = note: inside closure at ***/tokio-1.36.0/src/runtime/scheduler/current_thread/mod.rs:659:25: 659:87 = note: inside `tokio::runtime::scheduler::current_thread::Context::enter::, {closure@tokio::runtime::scheduler::current_thread::CoreGuard<'_>::block_on>>>::{closure#0}::{closure#0}}>` at ***/tokio-1.36.0/src/runtime/scheduler/current_thread/mod.rs:404:19: 404:22 = note: inside closure at ***/tokio-1.36.0/src/runtime/scheduler/current_thread/mod.rs:658:36: 660:23 = note: inside closure at ***/tokio-1.36.0/src/runtime/scheduler/current_thread/mod.rs:737:68: 737:84 = note: inside `tokio::runtime::context::scoped::Scoped::::set::<{closure@tokio::runtime::scheduler::current_thread::CoreGuard<'_>::enter<{closure@tokio::runtime::scheduler::current_thread::CoreGuard<'_>::block_on>>>::{closure#0}}, std::option::Option<()>>::{closure#0}}, (std::boxed::Box, std::option::Option<()>)>` at ***/tokio-1.36.0/src/runtime/context/scoped.rs:40:9: 40:12 = note: inside closure at ***/tokio-1.36.0/src/runtime/context.rs:176:26: 176:47 = note: inside `std::thread::LocalKey::::try_with::<{closure@tokio::runtime::context::set_scheduler<(std::boxed::Box, std::option::Option<()>), {closure@tokio::runtime::scheduler::current_thread::CoreGuard<'_>::enter<{closure@tokio::runtime::scheduler::current_thread::CoreGuard<'_>::block_on>>>::{closure#0}}, std::option::Option<()>>::{closure#0}}>::{closure#0}}, (std::boxed::Box, std::option::Option<()>)>` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:286:16: 286:31 = note: inside `std::thread::LocalKey::::with::<{closure@tokio::runtime::context::set_scheduler<(std::boxed::Box, std::option::Option<()>), {closure@tokio::runtime::scheduler::current_thread::CoreGuard<'_>::enter<{closure@tokio::runtime::scheduler::current_thread::CoreGuard<'_>::block_on>>>::{closure#0}}, std::option::Option<()>>::{closure#0}}>::{closure#0}}, (std::boxed::Box, std::option::Option<()>)>` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:262:9: 262:25 = note: inside `tokio::runtime::context::set_scheduler::<(std::boxed::Box, std::option::Option<()>), {closure@tokio::runtime::scheduler::current_thread::CoreGuard<'_>::enter<{closure@tokio::runtime::scheduler::current_thread::CoreGuard<'_>::block_on>>>::{closure#0}}, std::option::Option<()>>::{closure#0}}>` at ***/tokio-1.36.0/src/runtime/context.rs:176:9: 176:48 = note: inside `tokio::runtime::scheduler::current_thread::CoreGuard::<'_>::enter::<{closure@tokio::runtime::scheduler::current_thread::CoreGuard<'_>::block_on>>>::{closure#0}}, std::option::Option<()>>` at ***/tokio-1.36.0/src/runtime/scheduler/current_thread/mod.rs:737:27: 737:85 = note: inside `tokio::runtime::scheduler::current_thread::CoreGuard::<'_>::block_on::>>>` at ***/tokio-1.36.0/src/runtime/scheduler/current_thread/mod.rs:646:19: 714:11 = note: inside closure at ***/tokio-1.36.0/src/runtime/scheduler/current_thread/mod.rs:175:28: 175:49 = note: inside `tokio::runtime::context::runtime::enter_runtime::<{closure@tokio::runtime::scheduler::current_thread::CurrentThread::block_on>>::{closure#0}}, ()>` at ***/tokio-1.36.0/src/runtime/context/runtime.rs:65:16: 65:38 = note: inside `tokio::runtime::scheduler::current_thread::CurrentThread::block_on::>>` at ***/tokio-1.36.0/src/runtime/scheduler/current_thread/mod.rs:167:9: 198:11 = note: inside `tokio::runtime::Runtime::block_on::>>` at ***/tokio-1.36.0/src/runtime/runtime.rs:348:47: 348:88 note: inside `core::reconciler::replica::tests::test_disown_missing_owners` --> control-plane/agents/core/src/core/reconciler/replica/tests.rs:86:5 | 86 | assert_eq!(num_replicas, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: inside closure --> control-plane/agents/core/src/core/reconciler/replica/tests.rs:16:38 | 15 | #[tokio::test] | -------------- | | | in this procedural macro expansion (#1) | in this procedural macro expansion (#2) 16 | async fn test_disown_missing_owners() { | ^ | ::: ***/tokio-macros-2.2.0/src/lib.rs:428:1 | 428 | pub fn test(args: TokenStream, item: TokenStream) -> TokenStream { | ---------------------------------------------------------------- in this expansion of `#[tokio::test]` (#1) | ::: /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/macros/mod.rs:1601:5 | 1601 | pub macro test($item:item) { | -------------- in this expansion of `#[::core::prelude::v1::test]` (#2) = note: inside `<{closure@control-plane/agents/core/src/core/reconciler/replica/tests.rs:16:7: 87:2} as std::ops::FnOnce<()>>::call_once - shim` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5: 250:71 = note: inside ` std::result::Result<(), std::string::String> as std::ops::FnOnce<()>>::call_once - shim(fn() -> std::result::Result<(), std::string::String>)` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5: 250:71 = note: inside `test::__rust_begin_short_backtrace::, fn() -> std::result::Result<(), std::string::String>>` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:620:18: 620:21 = note: inside `test::types::RunnableTest::run` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/types.rs:146:40: 146:71 = note: inside closure at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:643:60: 643:79 = note: inside ` as std::ops::FnOnce<()>>::call_once` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:272:9: 272:19 = note: inside `std::panicking::r#try::do_call::, std::result::Result<(), std::string::String>>` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:554:40: 554:43 = note: inside `std::panicking::r#try::, std::panic::AssertUnwindSafe<{closure@test::run_test_in_process::{closure#0}}>>` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:518:19: 518:81 = note: inside `std::panic::catch_unwind::, std::result::Result<(), std::string::String>>` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:142:14: 142:33 = note: inside `test::run_test_in_process` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:643:27: 643:81 = note: inside closure at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:566:43: 574:18 = note: inside closure at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:594:41: 594:83 = note: inside `std::sys_common::backtrace::__rust_begin_short_backtrace::<{closure@test::run_test::{closure#1}}, ()>` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:155:18: 155:21 = note: inside closure at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:529:17: 529:78 = note: inside `::{closure#1}::{closure#0}}> as std::ops::FnOnce<()>>::call_once` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:272:9: 272:19 = note: inside `std::panicking::r#try::do_call::::{closure#1}::{closure#0}}>, ()>` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:554:40: 554:43 = note: inside `std::panicking::r#try::<(), std::panic::AssertUnwindSafe<{closure@std::thread::Builder::spawn_unchecked_<'_, '_, {closure@test::run_test::{closure#1}}, ()>::{closure#1}::{closure#0}}>>` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:518:19: 518:81 = note: inside `std::panic::catch_unwind::::{closure#1}::{closure#0}}>, ()>` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:142:14: 142:33 = note: inside closure at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:528:30: 530:16 = note: inside `<{closure@std::thread::Builder::spawn_unchecked_<'_, '_, {closure@test::run_test::{closure#1}}, ()>::{closure#1}} as std::ops::FnOnce<()>>::call_once - shim(vtable)` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5: 250:71 = note: inside ` as std::ops::FnOnce<()>>::call_once` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:2016:9: 2016:52 = note: inside `> as std::ops::FnOnce<()>>::call_once` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:2016:9: 2016:52 = note: inside `std::sys::pal::unix::thread::Thread::new::thread_start` at /home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/pal/unix/thread.rs:108:17: 108:64 error: aborting due to 1 previous error; 14 warnings emitted error: test failed, to rerun pass `-p agents --bin core` Caused by: process didn't exit successfully: `/home/da5h/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo-miri runner ****/target/miri/x86_64-unknown-linux-gnu/debug/deps/core-1f540b72a054c63c` (exit status: 1) note: test exited abnormally; to see the full output pass --nocapture to the harness. ```
RalfJung commented 8 months ago

The actual issue here is posix_spawn -- there's little point in supporting gnu_get_libc_version as you'd just be stuck with the next error. Miri just doesn't support the Command API currently.