fitzgen / bumpalo

A fast bump allocation arena for Rust
https://docs.rs/bumpalo
Apache License 2.0
1.39k stars 110 forks source link

Set up testing with miri #55

Closed fitzgen closed 2 years ago

fitzgen commented 4 years ago

Copying the miri CI script from the typed-arena crate:

miri CI script ``` set -ex MIRI_NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri) echo "Installing latest nightly with Miri: $MIRI_NIGHTLY" rustup default "$MIRI_NIGHTLY" cargo clean rustup component add miri cargo miri setup cargo miri test ```

Still waiting on the full test suite to finish running, this is taking quite a bit longer than I'd anticipated.

However, the realloc tests are definitely failing, and I'm not sure I totally understand what miri is complaining about here. cc @RalfJung

realloc failure logs ``` error: Miri evaluation error: a raw memory access tried to access part of a pointer value as raw bytes --> /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/intrinsics.rs:1549:5 | 1549 | copy(src, dst, count) | ^^^^^^^^^^^^^^^^^^^^^ Miri evaluation error: a raw memory access tried to access part of a pointer value as raw bytes | note: inside call to `core::intrinsics::copy::` at src/lib.rs:1070:17 --> src/lib.rs:1070:17 | 1070 | ptr::copy(ptr.as_ptr(), p.as_ptr(), new_size); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: inside call to `<&Bump as alloc::Alloc>::realloc` at src/lib.rs:1118:21 --> src/lib.rs:1118:21 | 1118 | let q = (&b).realloc(p, layout, 11).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: inside call to `tests::test_realloc` at src/lib.rs:1094:5 --> src/lib.rs:1094:5 | 1094 | / fn test_realloc() { 1095 | | use crate::alloc::Alloc; 1096 | | 1097 | | unsafe { ... | 1138 | | } 1139 | | } | |_____^ = note: inside call to closure at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/ops/function.rs:232:5 = note: inside call to `<[closure@src/lib.rs:1094:5: 1139:6] as core::ops::FnOnce<()>>::call_once - shim` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/ops/function.rs:232:5 = note: inside call to `>::call_once - shim(fn())` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libtest/lib.rs:543:5 = note: inside call to `tests::test::__rust_begin_short_backtrace::` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libtest/lib.rs:534:30 = note: inside call to closure at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/ops/function.rs:232:5 = note: inside call to `<[closure@DefId(5:635 ~ test[cf55]::run_test[0]::{{closure}}[3]) 0:fn()] as core::ops::FnOnce<()>>::call_once - shim(vtable)` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/liballoc/boxed.rs:1022:9 = note: inside call to ` as core::ops::FnOnce<()>>::call_once` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panic.rs:318:9 = note: inside call to `> as core::ops::FnOnce<()>>::call_once` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panicking.rs:292:40 = note: inside call to `std::panicking::r#try::do_call::>, ()>` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panicking.rs:270:13 = note: inside call to `std::panicking::r#try::<(), std::panic::AssertUnwindSafe>>` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panic.rs:394:14 = note: inside call to `std::panic::catch_unwind::>, ()>` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libtest/lib.rs:567:18 = note: inside call to `tests::test::run_test_in_process` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libtest/lib.rs:474:21 = note: inside call to closure at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libtest/lib.rs:495:13 = note: inside call to `tests::test::run_test::run_test_inner` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libtest/lib.rs:531:28 = note: inside call to `tests::test::run_test` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libtest/lib.rs:300:13 = note: inside call to `tests::test::run_tests::<[closure@DefId(5:427 ~ test[cf55]::console[0]::run_tests_console[0]::{{closure}}[2]) 0:&mut tests::test::console::ConsoleTestState, 1:&mut core_alloc::boxed::Box]>` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libtest/console.rs:295:5 = note: inside call to `tests::test::run_tests_console` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libtest/lib.rs:121:15 = note: inside call to `tests::test::test_main` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libtest/lib.rs:140:5 = note: inside call to `tests::test::test_main_static` = note: inside call to `main` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:67:34 = note: inside call to closure at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:52:73 = note: inside call to closure at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/sys_common/backtrace.rs:136:5 = note: inside call to `std::sys_common::backtrace::__rust_begin_short_backtrace::<[closure@DefId(6:6014 ~ std[848d]::rt[0]::lang_start_internal[0]::{{closure}}[0]::{{closure}}[0]) 0:&dyn core::ops::Fn() -> i32 + core::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:52:13 = note: inside call to closure at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panicking.rs:292:40 = note: inside call to `std::panicking::r#try::do_call::<[closure@DefId(6:6013 ~ std[848d]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn core::ops::Fn() -> i32 + core::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panicking.rs:270:13 = note: inside call to `std::panicking::r#try:: i32 + core::marker::Sync + std::panic::RefUnwindSafe]>` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panic.rs:394:14 = note: inside call to `std::panic::catch_unwind::<[closure@DefId(6:6013 ~ std[848d]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn core::ops::Fn() -> i32 + core::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:51:25 = note: inside call to `std::rt::lang_start_internal` at /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:67:5 = note: inside call to `std::rt::lang_start::<()>` error: aborting due to previous error test tests::test_realloc ... error: could not compile `bumpalo`. To learn more, run the command again with --verbose. ```
RalfJung commented 4 years ago

This log:

error: Miri evaluation error: a raw memory access tried to access part of a pointer value as raw bytes
    --> /home/fitzgen/.rustup/toolchains/nightly-2019-12-15-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/intrinsics.rs:1549:5
     |
1549 |     copy(src, dst, count)
     |     ^^^^^^^^^^^^^^^^^^^^^ Miri evaluation error: a raw memory access tried to access part of a pointer value as raw bytes
     |
note: inside call to `core::intrinsics::copy::<u8>` at src/lib.rs:1070:17
    --> src/lib.rs:1070:17
     |
1070 |                 ptr::copy(ptr.as_ptr(), p.as_ptr(), new_size);
     |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

looks like you are byte-wise copying a pointer. Miri doesn't currently support that. We certainly want to (there are, somewhat surprisingly, some hard questions around this, but at least for now Miri is not intended to explore those). The most immediate blocker is https://github.com/rust-lang/miri/issues/841.

zetanumbers commented 2 years ago

Fixed on main + current nightly

konsumlamm commented 2 years ago

With #168 merged, the CI now runs miri tests with all features.