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

API soundness issue in raw_slice and raw_slice_mut #201

Open
Qwaz opened this issue Feb 11, 2020 · 1 comment
Open

API soundness issue in raw_slice and raw_slice_mut #201

Qwaz opened this issue Feb 11, 2020 · 1 comment

Comments

@Qwaz
Copy link

Qwaz commented Feb 11, 2020

The current definition of raw_slice and raw_slice_mut creates 'a bounded reference from &self. Since the returned slice is created from a stored pointer in &self, it should be bounded by 'self lifetime instead of 'a.

With the current definitions of those methods, it is possible to cause data race with safe Rust code.

use rulinalg::matrix;
use rulinalg::matrix::BaseMatrixMut;

fn main() {
    let mut mat = matrix![0];

    let mut row = mat.row_mut(0);

    // this creates mutable aliases to the same location
    let raw_slice1 = row.raw_slice_mut();
    let raw_slice2 = row.raw_slice_mut();

    assert_eq!(raw_slice1[0], 0);
    raw_slice2[0] = 1;
    assert_eq!(raw_slice1[0], 0);
}
@garro95
Copy link

garro95 commented Feb 11, 2020

Unfortunately, this crate is not being maintained anymore. As you can see, last commit was in 2017. I suggest you to switch to nalgebra if it fits your needs.

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

2 participants