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 complaints with remove_fixed_columns/rows #1472

Open
TomFryersMidsummer opened this issue Jan 13, 2025 · 0 comments
Open

Miri complaints with remove_fixed_columns/rows #1472

TomFryersMidsummer opened this issue Jan 13, 2025 · 0 comments

Comments

@TomFryersMidsummer
Copy link

Miri can flag errors in code that uses remove_fixed_columns (or remove_fixed_rows). It would be nice for it not to.
Cargo.toml:

[package]
name = "nalgebra-miri-error"
edition = "2024"

[dependencies]
nalgebra = "0.33.2"

src/lib.rs:

#[cfg(test)]
mod tests {
    use nalgebra::SMatrix;

    #[test]
    fn it_works() {
        let n: SMatrix<u32, 1, 1> = SMatrix::<u32, 1, 2>::zeros().remove_fixed_columns::<1>(0);
    }
}

cargo +nightly miri test
test tests::it_works ... error: Undefined Behavior: attempting a read access using <277439> at alloc114585[0x4], but that tag does not exist in the borrow stack for this location
   --> ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/nalgebra-0.33.2/src/base/edition.rs:519:17
    |
519 | /                 ptr::copy(
520 | |                     ptr_in,
521 | |                     ptr_out,
522 | |                     (ncols.value() - copied_value_start) * nrows.value(),
523 | |                 );
    | |                 ^
    | |                 |
    | |_________________attempting a read access using <277439> at alloc114585[0x4], but that tag does not exist in the borrow stack for this location
    |                   this error occurs as part of an access at alloc114585[0x4..0x8]
    |
    = 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: <277439> was created by a SharedReadOnly retag at offsets [0x0..0x8]
   --> src/lib.rs:7:37
    |
7   |         let n: SMatrix<u32, 1, 1> = SMatrix::<u32, 1, 2>::zeros().remove_fixed_columns::<1>(0);
    |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: <277439> was later invalidated at offsets [0x0..0x8] by a Unique function-entry retag inside this call
   --> src/lib.rs:7:37
    |
7   |         let n: SMatrix<u32, 1, 1> = SMatrix::<u32, 1, 2>::zeros().remove_fixed_columns::<1>(0);
    |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: BACKTRACE (of the first span) on thread `tests::it_works`:
    = note: inside `nalgebra::base::edition::<impl nalgebra::Matrix<u32, nalgebra::Const<1>, nalgebra::Const<2>, nalgebra::ArrayStorage<u32, 1, 2>>>::remove_columns_generic::<nalgebra::Const<1>>` at ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/nalgebra-0.33.2/src/base/edition.rs:519:17: 523:18
    = note: inside `nalgebra::base::edition::<impl nalgebra::Matrix<u32, nalgebra::Const<1>, nalgebra::Const<2>, nalgebra::ArrayStorage<u32, 1, 2>>>::remove_fixed_columns::<1>` at ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/nalgebra-0.33.2/src/base/edition.rs:471:9: 471:51
note: inside `tests::it_works`
   --> src/lib.rs:7:37
    |
7   |         let n: SMatrix<u32, 1, 1> = SMatrix::<u32, 1, 2>::zeros().remove_fixed_columns::<1>(0);
    |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside closure
   --> src/lib.rs:6:18
    |
5   |     #[test]
    |     ------- in this procedural macro expansion
6   |     fn it_works() {
    |                  ^
    = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
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