-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
Data race found by miri test
#279
Comments
Thank you for reporting! I will take a look.
It seems an older version of Moka (v0.9.x) was used in Materialize. moka = { version = "0.9.6", default-features = false, features = ["sync"] } Do your segfault issues remain in the latest version of Moka (v0.11.2)? It will not be related to the issues but we fixed one incorrect |
Thanks for the quick reply! Unfortunately we didn't have the chance to try v0.11 as the segfault was preventing a production release. If we ever do get the chance to try it, I'll be sure to update this issue! |
Thanks for the reply.
Understood. I ran
$ cargo +nightly miri test --lib cht::segment::tests::concurrent_overlapped_removal
...
error: Undefined Behavior: Data race detected between (1) Read on thread `<unnamed>` and (2) Write on thread `<unnamed>` at alloc123212. (2) just happened here
--> /Users/tatsuya/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.15/src/atomic.rs:208:9
|
208 | &mut *(ptr as *mut T)
| ^^^^^^^^^^^^^^^^^^^^^ Data race detected between (1) Read on thread `<unnamed>` and (2) Write on thread `<unnamed>` at alloc123212. (2) just happened here I lightly reviewed some of the errors and relevant codes in moka but it seems we are using crossbeam-epoch correctly. I will review again and maybe check with the maintainers of crossbeam-epoch if they have any opinions. |
Asked the question: crossbeam-rs/crossbeam#993 |
I reviewed Miri's data race errors on the following tests, created a minimum code to reproduce, and asked some questions to a maintainer of
And our conclusion is these Miri errors are most likely false positives. We found no issues in relevant code in Here are the details:
Running Miri with the workaround in
crossbeam-epoch = { git = "https://github.com/crossbeam-rs/crossbeam.git", branch = "master", optional = true } Terminal Log (macOS arm64) $ cargo tree -i crossbeam-epoch
crossbeam-epoch v0.9.15 (https://github.com/crossbeam-rs/crossbeam.git?branch=master#ce31c186)
└── moka v0.11.2 (...)
$ MIRIFLAGS="-Zmiri-tree-borrows" cargo +nightly miri test --lib cht::segment::tests::concurrent_overlapped_removal
Preparing a sysroot for Miri (target: aarch64-apple-darwin)... done
WARNING: Ignoring `RUSTC_WRAPPER` environment variable, Miri does not support wrapping.
Finished test [unoptimized + debuginfo] target(s) in 0.08s
Running unittests src/lib.rs (target/miri/aarch64-apple-darwin/debug/deps/moka-451ea5dfd08c9c07)
running 1 test
test cht::segment::tests::concurrent_overlapped_removal ... ^C
## Pressed Ctrl + C after ~1 minute. Otherwise it can take few hours to complete. |
FYI, I am trying to reproduce the memory corruption (segmentation fault) using mokabench, a load generator I run for few hours before releasing I made some modifications, and ran it on macOS arm64 and Linux x86_64. But I have not had a chance to reproduce the issue.
|
To be clear: As for consume memory ordering, I don't think it's a problem with Miri's weak memory model emulation. There is no API in the Rust standard library to express it, so the data race detector for Rust just doesn't support it. |
Ah, I misunderstood.
Now I have better understanding. Thanks for clarifying! |
I continued investigating the original memory corruption issue in Materialize with Moka v0.9.6, and I published v0.9.8 to crates.io with a potential fix.
For more details, see #281 (comment). |
Commit:
d74d1e3c7cd922577767c8c2f9a8bdf7b7018e69
Rust Version:
cargo 1.70.0-nightly (0e474cfd7 2023-03-31)
OS: macOS 13.4
CPU: Apple M2 Max
Running
cargo +nightly miri test
in the root of the crate, fails on the first test:with the error:
I also disabled the race detector with
MIRIFLAGS="-Zmiri-disable-data-race-detector"
, but when running with this flag the test never completes.Note: I started looking into Moka because recently we tried using it in MaterializeInc/materialize#19614, but had to revert it because we were observing memory corruption.
Full Stack Trace:
The text was updated successfully, but these errors were encountered: