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

miri shows undefined behaviour when run with -Zmiri-tag-raw-pointers #37

Closed
jrmuizel opened this issue Jun 12, 2022 · 1 comment
Closed

Comments

@jrmuizel
Copy link
Collaborator

test tests::extra_free ... error: Undefined Behavior: trying to reborrow <248731> for SharedReadWrite permission at alloc96889[0x22], but that tag only grants SharedReadOnly permission for this location
    --> /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:487:1
     |
487  | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     | |
     | trying to reborrow <248731> for SharedReadWrite permission at alloc96889[0x22], but that tag only grants SharedReadOnly permission for this location
     | this error occurs as part of a reborrow at alloc96889[0x0..0x28]
     |
     = help: this indicates a potential bug in the program: it performed an invalid operation, but the 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: <248731> was created by a retag at offsets [0x0..0x28]
    --> src/collect.rs:311:24
     |
311  |             white.push(s.into());
     |                        ^^^^^^^^
     = note: inside `std::ptr::drop_in_place::<dyn cc_box_ptr::CcBoxPtr> - shim(Some(dyn cc_box_ptr::CcBoxPtr))` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:487:1
note: inside `drop_value` at src/lib.rs:922:5
    --> src/lib.rs:922:5
     |
922  |     ptr::drop_in_place(ptr.as_ptr());
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `collect::collect_roots` at src/collect.rs:338:18
    --> src/collect.rs:338:18
     |
338  |         unsafe { crate::drop_value(*i) };
     |                  ^^^^^^^^^^^^^^^^^^^^^
note: inside `collect::collect_cycles` at src/collect.rs:192:5
    --> src/collect.rs:192:5
     |
192  |     collect_roots();
     |     ^^^^^^^^^^^^^^^
note: inside `tests::extra_free` at src/lib.rs:1367:13
    --> src/lib.rs:1367:13
     |
1367 |             collect_cycles(); // <- incorrectly? frees env_a.
     |             ^^^^^^^^^^^^^^^^
note: inside closure at src/lib.rs:1314:5
    --> src/lib.rs:1314:5
     |
1313 |       #[test]
     |       ------- in this procedural macro expansion
1314 | /     fn extra_free() {
1315 | |         struct Env {
1316 | |             pub closures: Vec<Cc<RefCell<Clos>>>,
1317 | |             pub next: Option<Cc<Env>>,
...    |
1381 | |         collect_cycles();
1382 | |     }
     | |_____^
     = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
@jrmuizel
Copy link
Collaborator Author

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

No branches or pull requests

1 participant