Skip to content

Violation of stacked borrows in abomonation tests #1011

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

Closed
saethlin opened this issue Oct 17, 2021 · 2 comments · Fixed by #1074
Closed

Violation of stacked borrows in abomonation tests #1011

saethlin opened this issue Oct 17, 2021 · 2 comments · Fixed by #1074

Comments

@saethlin
Copy link
Contributor

None of the abomonation tests in this crate pass miri because they all invoke UB by producing improperly-aligned references and doing improperly-aligned reads. That level of UB is par for the course with abomonation, but this one also violates stacked borrows:

$ cargo miri test --all-features --no-fail-fast abomonate_point3
    Finished test [unoptimized + debuginfo] target(s) in 0.04s
     Running unittests (target/miri/x86_64-unknown-linux-gnu/debug/deps/nalgebra-8bb505112d667bf7)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 20 filtered out

     Running tests/lib.rs (target/miri/x86_64-unknown-linux-gnu/debug/deps/lib-17c301152c55f7ae)

running 1 test
test core::abomonation::abomonate_point3 ... error: Undefined Behavior: trying to reborrow for Unique at alloc644077+0x1, but parent tag <1628945> does not have an appropriate item in the borrow stack
   --> /home/ben/.cargo/registry/src/github.com-1ecc6299db9ec823/abomonation-0.7.3/src/lib.rs:127:30
    |
127 |         let result: &mut T = mem::transmute(split1.get_unchecked_mut(0));
    |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to reborrow for Unique at alloc644077+0x1, but parent tag <1628945> does not have an appropriate item in the borrow stack
    |
    = 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

    = note: inside `abomonation::decode::<na::OPoint<f32, na::Const<3_usize>>>` at /home/ben/.cargo/registry/src/github.com-1ecc6299db9ec823/abomonation-0.7.3/src/lib.rs:127:30

@sebcrozet
Copy link
Member

sebcrozet commented Nov 21, 2021

Thank you for pointing this out. I think we should simply completely remove the support for abomonation from nalgebra.

It is inherently unsafe, doesn’t seem to be actively maintained anymore, and doesn’t really appears to be very popular. I feel like it made sense to support this in the 4 years ago, when the serialization scene wasn’t super well developed in Rust. Now it seems like there are better and safer alternative.

@edibopp You added the support for abomonation in #279. Where do you stand today wrt. abomonation and it’s possible removal from nalgebra?

@milibopp
Copy link
Collaborator

milibopp commented Dec 2, 2021

Hm… I'm so far removed from development today, that I would not want to object. I was using this for some high-performance computation stuff years ago, but have long lost touch with my use case. I doubt anyone else is still using it, but I don't know for sure.

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

Successfully merging a pull request may close this issue.

3 participants