-
Notifications
You must be signed in to change notification settings - Fork 50
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
Miri reports UB in tests #145
Comments
I don't have time to debug this, but I bet this is mostly because this crate was written a while ago before a lot of this stuff was pinned down and it's doing some pointer stuff in a way that's not ideal. In particular, we're doing pointer masking, which probably falls afoul of strict provenance. |
If that is the issue, it might be easy to fix using https://crates.io/crates/sptr. |
My understanding was that strict provenance was something that was optional in miri, however. Unsure if I want to add new deps for it ust yet, might want to wait till those things are in stable. |
Fixes Manishearth#145. Signed-off-by: Anders Kaseorg <[email protected]>
I was able to reproduce and find a simple fix: #146. |
Can confirm that PR did fix this specific error, however miri still reports UB (specifically in Errorerror: Undefined Behavior: attempting a write access using <210556> at alloc88933[0x38], but that tag does not exist in the borrow stack for this location
--> /workspaces/rust-gc/gc/src/gc.rs:231:13
|
231 | *incoming = node.header.next.take();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| attempting a write access using <210556> at alloc88933[0x38], but that tag does not exist in the borrow stack for this location
| this error occurs as part of an access at alloc88933[0x38..0x48]
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <210556> was created by a retag at offsets [0x38..0x48]
--> /workspaces/rust-gc/gc/src/gc.rs:213:31
|
213 | incoming: unmark_head,
| ^^^^^^^^^^^
help: <210556> was later invalidated at offsets [0x38..0x48]
--> /workspaces/rust-gc/gc/src/gc.rs:243:14
|
243 | mark(&mut st.boxes_start);
| ^^^^^^^^^^^^^^^^^^^
= note: backtrace:
= note: inside `gc::gc::collect_garbage::sweep` at /workspaces/rust-gc/gc/src/gc.rs:231:13
note: inside `gc::gc::collect_garbage` at /workspaces/rust-gc/gc/src/gc.rs:244:9
--> /workspaces/rust-gc/gc/src/gc.rs:244:9
|
244 | sweep(unmarked, &mut st.stats.bytes_allocated);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `<gc::gc::GcState as std::ops::Drop>::drop` at /workspaces/rust-gc/gc/src/gc.rs:15:13
--> /workspaces/rust-gc/gc/src/gc.rs:15:13
|
15 | collect_garbage(self);
| ^^^^^^^^^^^^^^^^^^^^^
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace Interestingly this error doesn't have an associated test and all tests pass, but I suppose that's just because it happens in the destructor of a threadlocal. |
Oh hmm, that one is a new error with this week’s nightlies.
Probably due to rust-lang/miri#2275, which was merged within that range. Indeed, earlier nightlies fail in the same way with |
#147 seems to fix everything. |
Haven't seen anyone mention this yet so I thought I'd open an issue here. Running the current tests under miri reports Undefined Behavior in
Gc<T>
's Drop impl:The text was updated successfully, but these errors were encountered: