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

ci: Enable miri for further cargo tests #18119

Merged
merged 1 commit into from
Mar 15, 2023
Merged

Conversation

def-
Copy link
Contributor

@def- def- commented Mar 14, 2023

This seems more fruitful than sanitizers which are not well supported with Rust yet. Most individual tests I disabled for miri in their specific location, when an entire directory seemed to fail I excluded it entirely in ci/test/cargo-test-miri.sh. This means that new tests outside of those directories will run in miri by default unless disabled.

What miri offers: https://github.com/rust-lang/miri

An experimental interpreter for Rust's mid-level intermediate representation (MIR). It can run binaries and test suites of cargo projects and detect certain classes of undefined behavior, for example: [...]

Fixes: https://github.com/MaterializeInc/database-issues/issues/5173

Motivation

  • This PR adds a known-desirable feature.

Checklist

  • This PR has adequate test coverage / QA involvement has been duly considered.
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • This PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way) and therefore is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).
  • This PR includes the following user-facing behavior changes:

@def- def- requested a review from philip-stoev March 14, 2023 15:28
@def- def- changed the title Try to enable miri for further cargo tests ci: Try to enable miri for further cargo tests Mar 14, 2023
@def- def- force-pushed the pr-miri-improve branch 2 times, most recently from b780b47 to 6662e6e Compare March 14, 2023 18:04
@def- def- marked this pull request as ready for review March 14, 2023 18:07
@def- def- requested a review from benesch as a code owner March 14, 2023 18:07
@def- def- requested review from a team March 14, 2023 18:07
@def- def- requested review from a team, aalexandrov and umanwizard as code owners March 14, 2023 18:07
@def- def- changed the title ci: Try to enable miri for further cargo tests ci: Enable miri for further cargo tests Mar 14, 2023
@@ -742,6 +742,7 @@ mod tests {
use super::*;

#[tokio::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `epoll_wait` on OS `linux`
Copy link
Contributor

@danhhz danhhz Mar 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting! most of these tests in persist that you've had to skip (AFAIK) don't need epoll, so I wonder if this is just [tokio::test]. looks like they're not planning to making it work with miri, but now I'm morbidly curious if these tests would be fine if we manually created the tokio Runtime without the io reactor running

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error: unsupported operation: can't call foreign function `epoll_wait` on OS `linux`
   --> /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/mio-0.8.5/src/sys/unix/selector/epoll.rs:106:9
    |
106 | /         syscall!(epoll_wait(
107 | |             self.ep,
108 | |             events.as_mut_ptr(),
109 | |             events.capacity() as i32,
110 | |             timeout,
111 | |         ))
    | |__________^ can't call foreign function `epoll_wait` 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 `mio::sys::unix::selector::epoll::Selector::select` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/mio-0.8.5/src/sys/unix/mod.rs:7:28: 7:49
    = note: inside `mio::poll::Poll::poll` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/mio-0.8.5/src/poll.rs:411:9: 411:61
    = note: inside `tokio::runtime::io::Driver::turn` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/io/mod.rs:172:15: 172:47
    = note: inside `tokio::runtime::io::Driver::park` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/io/mod.rs:138:9: 138:32
    = note: inside `tokio::runtime::signal::Driver::park` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/signal/mod.rs:92:9: 92:29
    = note: inside `tokio::runtime::process::Driver::park` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/process.rs:32:9: 32:31
    = note: inside `tokio::runtime::driver::IoStack::park` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/driver.rs:162:40: 162:54
    = note: inside `tokio::runtime::time::Driver::park_internal` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/time/mod.rs:211:21: 211:46
    = note: inside `tokio::runtime::time::Driver::park` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/time/mod.rs:152:9: 152:41
    = note: inside `tokio::runtime::driver::TimeDriver::park` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/driver.rs:306:55: 306:74
    = note: inside `tokio::runtime::driver::Driver::park` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/driver.rs:63:9: 63:32
    = note: inside `tokio::runtime::scheduler::multi_thread::park::Inner::park_driver` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/scheduler/multi_thread/park.rs:189:9: 189:28
    = note: inside `tokio::runtime::scheduler::multi_thread::park::Inner::park` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/scheduler/multi_thread/park.rs:122:13: 122:50
    = note: inside `tokio::runtime::scheduler::multi_thread::park::Parker::park` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/scheduler/multi_thread/park.rs:68:9: 68:32
    = note: inside `tokio::runtime::scheduler::multi_thread::worker::Context::park_timeout` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/scheduler/multi_thread/worker.rs:560:13: 560:50
    = note: inside `tokio::runtime::scheduler::multi_thread::worker::Context::park` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/scheduler/multi_thread/worker.rs:531:24: 531:53
    = note: inside `tokio::runtime::scheduler::multi_thread::worker::Context::run` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/scheduler/multi_thread/worker.rs:439:21: 439:36
    = note: inside closure at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/scheduler/multi_thread/worker.rs:406:17: 406:29
    = note: inside `tokio::macros::scoped_tls::ScopedKey::<tokio::runtime::scheduler::multi_thread::worker::Context>::set::<[closure@tokio::runtime::scheduler::multi_thread::worker::run::{closure#0}], ()>` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/macros/scoped_tls.rs:61:9: 61:12
    = note: inside `tokio::runtime::scheduler::multi_thread::worker::run` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/scheduler/multi_thread/worker.rs:403:5: 412:7
    = note: inside closure at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/scheduler/multi_thread/worker.rs:365:45: 365:56
    = note: inside `<tokio::runtime::blocking::task::BlockingTask<[closure@tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{closure#0}]> as futures_util::Future>::poll` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/blocking/task.rs:42:21: 42:27
    = note: inside closure at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/task/core.rs:223:17: 223:37
    = note: inside `tokio::loom::std::unsafe_cell::UnsafeCell::<tokio::runtime::task::core::Stage<tokio::runtime::blocking::task::BlockingTask<[closure@tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{closure#0}]>>>::with_mut::<futures_task::Poll<()>, [closure@tokio::runtime::task::core::Core<tokio::runtime::blocking::task::BlockingTask<[closure@tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{closure#0}]>, tokio::runtime::blocking::schedule::BlockingSchedule>::poll::{closure#0}]>` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/loom/std/unsafe_cell.rs:14:9: 14:24
    = note: inside `tokio::runtime::task::core::Core::<tokio::runtime::blocking::task::BlockingTask<[closure@tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{closure#0}]>, tokio::runtime::blocking::schedule::BlockingSchedule>::poll` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/task/core.rs:212:13: 224:15
    = note: inside closure at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/task/harness.rs:476:19: 476:38
    = note: inside `<std::panic::AssertUnwindSafe<[closure@tokio::runtime::task::harness::poll_future<tokio::runtime::blocking::task::BlockingTask<[closure@tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{closure#0}]>, tokio::runtime::blocking::schedule::BlockingSchedule>::{closure#0}]> as std::ops::FnOnce<()>>::call_once` at /home/deen/.rustup/toolchains/nightly-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@tokio::runtime::task::harness::poll_future<tokio::runtime::blocking::task::BlockingTask<[closure@tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{closure#0}]>, tokio::runtime::blocking::schedule::BlockingSchedule>::{closure#0}]>, futures_task::Poll<()>>` at /home/deen/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:487:40: 487:43
    = note: inside `std::panicking::r#try::<futures_task::Poll<()>, std::panic::AssertUnwindSafe<[closure@tokio::runtime::task::harness::poll_future<tokio::runtime::blocking::task::BlockingTask<[closure@tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{closure#0}]>, tokio::runtime::blocking::schedule::BlockingSchedule>::{closure#0}]>>` at /home/deen/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:451:19: 451:81
    = note: inside `std::panic::catch_unwind::<std::panic::AssertUnwindSafe<[closure@tokio::runtime::task::harness::poll_future<tokio::runtime::blocking::task::BlockingTask<[closure@tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{closure#0}]>, tokio::runtime::blocking::schedule::BlockingSchedule>::{closure#0}]>, futures_task::Poll<()>>` at /home/deen/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:140:14: 140:33
    = note: inside `tokio::runtime::task::harness::poll_future::<tokio::runtime::blocking::task::BlockingTask<[closure@tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{closure#0}]>, tokio::runtime::blocking::schedule::BlockingSchedule>` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/task/harness.rs:464:18: 479:8
    = note: inside `tokio::runtime::task::harness::Harness::<tokio::runtime::blocking::task::BlockingTask<[closure@tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{closure#0}]>, tokio::runtime::blocking::schedule::BlockingSchedule>::poll_inner` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/task/harness.rs:198:27: 198:55
    = note: inside `tokio::runtime::task::harness::Harness::<tokio::runtime::blocking::task::BlockingTask<[closure@tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{closure#0}]>, tokio::runtime::blocking::schedule::BlockingSchedule>::poll` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/task/harness.rs:152:15: 152:32
    = note: inside `tokio::runtime::task::raw::poll::<tokio::runtime::blocking::task::BlockingTask<[closure@tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{closure#0}]>, tokio::runtime::blocking::schedule::BlockingSchedule>` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/task/raw.rs:255:5: 255:19
    = note: inside `tokio::runtime::task::raw::RawTask::poll` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/task/raw.rs:200:18: 200:41
    = note: inside `tokio::runtime::task::UnownedTask::<tokio::runtime::blocking::schedule::BlockingSchedule>::run` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/task/mod.rs:431:9: 431:19
    = note: inside `tokio::runtime::blocking::pool::Task::run` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/blocking/pool.rs:159:9: 159:24
    = note: inside `tokio::runtime::blocking::pool::Inner::run` at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/blocking/pool.rs:511:17: 511:27
    = note: inside closure at /home/deen/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.2/src/runtime/blocking/pool.rs:469:13: 469:54
    = note: inside `std::sys_common::backtrace::__rust_begin_short_backtrace::<[closure@tokio::runtime::blocking::pool::Spawner::spawn_thread::{closure#0}], ()>` at /home/deen/.rustup/toolchains/nightly-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/deen/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:560:17: 560:78
    = note: inside `<std::panic::AssertUnwindSafe<[closure@std::thread::Builder::spawn_unchecked_<'_, '_, [closure@tokio::runtime::blocking::pool::Spawner::spawn_thread::{closure#0}], ()>::{closure#1}::{closure#0}]> as std::ops::FnOnce<()>>::call_once` at /home/deen/.rustup/toolchains/nightly-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@tokio::runtime::blocking::pool::Spawner::spawn_thread::{closure#0}], ()>::{closure#1}::{closure#0}]>, ()>` at /home/deen/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:487:40: 487:43
    = note: inside `std::panicking::r#try::<(), std::panic::AssertUnwindSafe<[closure@std::thread::Builder::spawn_unchecked_<'_, '_, [closure@tokio::runtime::blocking::pool::Spawner::spawn_thread::{closure#0}], ()>::{closure#1}::{closure#0}]>>` at /home/deen/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:451:19: 451:81
    = note: inside `std::panic::catch_unwind::<std::panic::AssertUnwindSafe<[closure@std::thread::Builder::spawn_unchecked_<'_, '_, [closure@tokio::runtime::blocking::pool::Spawner::spawn_thread::{closure#0}], ()>::{closure#1}::{closure#0}]>, ()>` at /home/deen/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:140:14: 140:33
    = note: inside closure at /home/deen/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:559:30: 561:16
    = note: inside `<[closure@std::thread::Builder::spawn_unchecked_<'_, '_, [closure@tokio::runtime::blocking::pool::Spawner::spawn_thread::{closure#0}], ()>::{closure#1}] as std::ops::FnOnce<()>>::call_once - shim(vtable)` at /home/deen/.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::boxed::Box<dyn std::ops::FnOnce()> as std::ops::FnOnce<()>>::call_once` at /home/deen/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1988:9: 1988:52
    = note: inside `<std::boxed::Box<std::boxed::Box<dyn std::ops::FnOnce()>> as std::ops::FnOnce<()>>::call_once` at /home/deen/.rustup/toolchains/nightly-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/deen/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/thread.rs:108:17: 108:64
    = note: this error originates in the macro `syscall` (in Nightly builds, run with -Z macro-backtrace for more info)

Indeed, looks tokio-specific. Repro with:

$ cd src/persist-client/src
$ MIRIFLAGS="-Zmiri-disable-isolation" cargo miri nextest run -j 16 --no-fail-fast --run-ignored ignored-only

(cd src/"$pkg" && cargo miri test miri --all-features)
done
export CARGO_TARGET_DIR="$PWD/miri-target"
export MIRIFLAGS="-Zmiri-disable-isolation"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would also be nice to enable -Zmiri-strict-provenance, if it doesn't cause too many more tests to fail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work fine, enabling.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@def- def- force-pushed the pr-miri-improve branch from 6662e6e to ffeffce Compare March 14, 2023 19:06
Copy link
Member

@benesch benesch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't review in depth, but I endorse the idea!

Copy link
Contributor

@philip-stoev philip-stoev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@def- def- merged commit 928a91f into MaterializeInc:main Mar 15, 2023
@def- def- deleted the pr-miri-improve branch March 15, 2023 08:09
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 this pull request may close these issues.

5 participants