Closed riking closed 7 months ago
Thanks for the report. This issue can be reproduced on the current versionn (0.23, 86a94ca502594d078b35c29ea3d1d68b34f16a28).
yilin@rat:~/Code/mmtk-core$ RUSTFLAGS="-Z sanitizer=address" cargo +nightly test --target x86_64-unknown-linux-gnu -- util::metadata::side_metadata::global::tests::test_u16_atomic_store
Finished test [unoptimized + debuginfo] target(s) in 0.06s
Running unittests src/lib.rs (target/x86_64-unknown-linux-gnu/debug/deps/mmtk-320a5c946a55f37c)
running 1 test
AddressSanitizer:DEADLYSIGNAL
=================================================================
==137718==ERROR: AddressSanitizer: SEGV on unknown address 0x018087ff8000 (pc 0x555bf1c1c28a bp 0x7efc4fafde10 sp 0x7efc4fafdd40 T1)
==137718==The signal is caused by a READ memory access.
#0 0x555bf1c1c28a (/home/yilin/Code/mmtk-core/target/x86_64-unknown-linux-gnu/debug/deps/mmtk-320a5c946a55f37c+0x92428a) (BuildId: 6961ca7e00eb1597651cea1dc17a32c7e4546cd2)
#1 0x555bf167540d (/home/yilin/Code/mmtk-core/target/x86_64-unknown-linux-gnu/debug/deps/mmtk-320a5c946a55f37c+0x37d40d) (BuildId: 6961ca7e00eb1597651cea1dc17a32c7e4546cd2)
#2 0x555bf1b8f02c (/home/yilin/Code/mmtk-core/target/x86_64-unknown-linux-gnu/debug/deps/mmtk-320a5c946a55f37c+0x89702c) (BuildId: 6961ca7e00eb1597651cea1dc17a32c7e4546cd2)
#3 0x555bf15ef560 (/home/yilin/Code/mmtk-core/target/x86_64-unknown-linux-gnu/debug/deps/mmtk-320a5c946a55f37c+0x2f7560) (BuildId: 6961ca7e00eb1597651cea1dc17a32c7e4546cd2)
#4 0x555bf1b63e4f (/home/yilin/Code/mmtk-core/target/x86_64-unknown-linux-gnu/debug/deps/mmtk-320a5c946a55f37c+0x86be4f) (BuildId: 6961ca7e00eb1597651cea1dc17a32c7e4546cd2)
#5 0x555bf184db3a (/home/yilin/Code/mmtk-core/target/x86_64-unknown-linux-gnu/debug/deps/mmtk-320a5c946a55f37c+0x555b3a) (BuildId: 6961ca7e00eb1597651cea1dc17a32c7e4546cd2)
#6 0x555bf1c4b4b6 (/home/yilin/Code/mmtk-core/target/x86_64-unknown-linux-gnu/debug/deps/mmtk-320a5c946a55f37c+0x9534b6) (BuildId: 6961ca7e00eb1597651cea1dc17a32c7e4546cd2)
#7 0x555bf1b1964b (/home/yilin/Code/mmtk-core/target/x86_64-unknown-linux-gnu/debug/deps/mmtk-320a5c946a55f37c+0x82164b) (BuildId: 6961ca7e00eb1597651cea1dc17a32c7e4546cd2)
#8 0x555bf1e16ffe (/home/yilin/Code/mmtk-core/target/x86_64-unknown-linux-gnu/debug/deps/mmtk-320a5c946a55f37c+0xb1effe) (BuildId: 6961ca7e00eb1597651cea1dc17a32c7e4546cd2)
#9 0x555bf1e15f74 (/home/yilin/Code/mmtk-core/target/x86_64-unknown-linux-gnu/debug/deps/mmtk-320a5c946a55f37c+0xb1df74) (BuildId: 6961ca7e00eb1597651cea1dc17a32c7e4546cd2)
#10 0x555bf1dde2f5 (/home/yilin/Code/mmtk-core/target/x86_64-unknown-linux-gnu/debug/deps/mmtk-320a5c946a55f37c+0xae62f5) (BuildId: 6961ca7e00eb1597651cea1dc17a32c7e4546cd2)
#11 0x555bf1de3446 (/home/yilin/Code/mmtk-core/target/x86_64-unknown-linux-gnu/debug/deps/mmtk-320a5c946a55f37c+0xaeb446) (BuildId: 6961ca7e00eb1597651cea1dc17a32c7e4546cd2)
#12 0x555bf2bccc54 (/home/yilin/Code/mmtk-core/target/x86_64-unknown-linux-gnu/debug/deps/mmtk-320a5c946a55f37c+0x18d4c54) (BuildId: 6961ca7e00eb1597651cea1dc17a32c7e4546cd2)
#13 0x555bf155132a (/home/yilin/Code/mmtk-core/target/x86_64-unknown-linux-gnu/debug/deps/mmtk-320a5c946a55f37c+0x25932a) (BuildId: 6961ca7e00eb1597651cea1dc17a32c7e4546cd2)
#14 0x7efc52a94ac2 (/lib/x86_64-linux-gnu/libc.so.6+0x94ac2) (BuildId: a43bfc8428df6623cd498c9c0caeb91aec9be4f9)
#15 0x7efc52b26a3f (/lib/x86_64-linux-gnu/libc.so.6+0x126a3f) (BuildId: a43bfc8428df6623cd498c9c0caeb91aec9be4f9)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/home/yilin/Code/mmtk-core/target/x86_64-unknown-linux-gnu/debug/deps/mmtk-320a5c946a55f37c+0x92428a) (BuildId: 6961ca7e00eb1597651cea1dc17a32c7e4546cd2)
Thread T1 created by T0 here:
#0 0x555bf153926d (/home/yilin/Code/mmtk-core/target/x86_64-unknown-linux-gnu/debug/deps/mmtk-320a5c946a55f37c+0x24126d) (BuildId: 6961ca7e00eb1597651cea1dc17a32c7e4546cd2)
#1 0x555bf2bcca9e (/home/yilin/Code/mmtk-core/target/x86_64-unknown-linux-gnu/debug/deps/mmtk-320a5c946a55f37c+0x18d4a9e) (BuildId: 6961ca7e00eb1597651cea1dc17a32c7e4546cd2)
==137718==ABORTING
error: test failed, to rerun pass `--lib`
Caused by:
process didn't exit successfully: `/home/yilin/Code/mmtk-core/target/x86_64-unknown-linux-gnu/debug/deps/mmtk-320a5c946a55f37c 'util::metadata::side_metadata::global::tests::test_u16_atomic_store'` (exit status: 1)
note: test exited abnormally; to see the full output pass --nocapture to the harness.
yilin@rat:~/Code/mmtk-core$ cargo +nightly --version
cargo 1.76.0-nightly (71cd3a926 2023-11-20)
I think this is a false alarm, and the reason is that we are using the address range in ASAN's shadow memory.
ASAN divides the address space into a few ranges. It reserves some ranges as shadow memory (metadata) so it can map other address ranges to a byte in the shadow memory. On x86_64, the following is what ASAN uses (ASAN_OPTIONS=verbosity=1
prints this). Basically we are allowed to use address ranges in HighMem
and LowMem
, but not the range in shadow memory. ShadowGap
is by default protected (and are not allowed to use), but can be unprotected by ASAN_OPTIONS=protect_shadow_gap=false
.
|| `[0x10007fff8000, 0x7fffffffffff]` || HighMem ||
|| `[0x02008fff7000, 0x10007fff7fff]` || HighShadow ||
|| `[0x00008fff7000, 0x02008fff6fff]` || ShadowGap ||
|| `[0x00007fff8000, 0x00008fff6fff]` || LowShadow ||
|| `[0x000000000000, 0x00007fff7fff]` || LowMem ||
MMTk currently uses 0x020000000000
to 0x220000000000
, which clashes with HighShadow
. Also the address range we use for side metadata starts from 0x0c0000000000
, also clashes with HighShadow
(it also clashes with the 6th space. See https://github.com/mmtk/mmtk-core/issues/458).
The line that ASAN reported was actually when we try to access side metadata at 0x0c0080000000
which is in the HighShadow
. ASAN reported SEGV at 0x01808fff8000
, which is a wrong address -- likely because we use addresses in the shadow memory and breaks their assumption on address arithmetic.
We could move the address range we use so it complies with ASAN which may not be a bad idea. But generally, I don't feel ASAN will be very helpful to us. It detects a few kinds of memory issues related with malloc
so it only detects issues in the Rust code and possibly only unsafe code we have). It might be interesting to us that ASAN allows users to manually poison memory -- so theoretically, we can use ASAN to check MMTk heap objects. ASAN works in a way that is similar to the VO bit for MMTk's allocated objects. We could consider implement something more powerful than VO bit and similar to ASAN in MMTk so we can check for MMTk allocated objects.
Hello, your tests from an old version (0.18.0) crash under AddressSanitizer:
https://asan.saethlin.dev/ub?crate=mmtk&version=0.18.0
Please check whether this crash still applies to the current version! (I couldn't find any existing issues discussing this.)