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

Multiplication of matrices with zero elements causes UB #644

Closed
sebcrozet opened this issue Sep 1, 2019 · 0 comments · Fixed by #645

Comments

@sebcrozet
Copy link
Member

commented Sep 1, 2019

The following test fails randomly:

#[test]
fn zero_mul() {
    let m = DMatrix::<f32>::zeros(8, 0);
    let v = DVector::<f32>::zeros(0);
    assert_eq!(m * v, DVector::zeros(8));
}

This is because nalgebra does not properly handle the case of 0-shaped matrices. Here the output matrix (for the multiplication result) is allocated with uninitialized values before performing the multiplication. Because the matrices are 0-shaped, nothing happen during the multiplication, causing the output matrix to remain uninitialized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.