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

Yank 2024-02-12 (possibly unsound impl valrow::Borrowable for Box<_>) #3

Closed
MaulingMonkey opened this issue Feb 13, 2024 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@MaulingMonkey
Copy link
Owner

MaulingMonkey commented Feb 13, 2024

Concerns were raised about Box's Unique / noalias requirements. Miri looks like it should be able to catch such bugs, but I haven't been able to convince my copy to catch any bugs in this test.

Testing

rustup toolchain install nightly -c miri

set RUSTFLAGS=--cfg xxx_borrowable_box
cargo +nightly miri test --all-features

set MIRIFLAGS=-Zmiri-unique-is-unique -Zmiri-tree-borrows
cargo +nightly miri test --all-features

References

valrow/src/borrowable.rs

Lines 143 to 167 in b38c862

#[cfg(xxx_borrowable_box)]
#[cfg(feature = "alloc")] #[test] fn try_to_break_box_valrows() {
let a = alloc::boxed::Box::new(core::cell::Cell::new(42));
let b = crate::Valrow::new(&a);
let c = &a;
a.set(1);
b.set(2); // possibly a problem?
c.set(3);
a.set(4);
b.set(5); // possibly a problem?
c.set(6);
let fmt = alloc::format!("{:?}", (&a, b, c));
#[cfg(feature = "std")] std::println!("{fmt}");
// Maybe the temp-Deref s aren't a problem, but would having a persistent pair of different-address `&Box<Cell<_>>`s trigger miri?
let b : &alloc::boxed::Box<_> = &*b;
a.set( 7);
b.set( 8); // possibly a problem?
c.set( 9);
a.set(10);
b.set(11); // possibly a problem?
c.set(12);
let fmt = alloc::format!("{:?}", (&a, b, c));
#[cfg(feature = "std")] std::println!("{fmt}");
}

@MaulingMonkey MaulingMonkey added the bug Something isn't working label Feb 13, 2024
@MaulingMonkey MaulingMonkey added this to the 2024-02-13 milestone Feb 13, 2024
@MaulingMonkey MaulingMonkey self-assigned this Feb 13, 2024
@MaulingMonkey
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant