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

Fix for #49489: Ensure length(ipiv)==n before calling LAPACK.getrs! to avoid segfaults #49602

Merged
merged 2 commits into from
May 3, 2023

Conversation

aravindh-krishnamoorthy
Copy link
Contributor

@aravindh-krishnamoorthy aravindh-krishnamoorthy commented May 2, 2023

Fixes #49489, where the tests for MultiScaleArrays.jl causes a segfault.

  1. The primary cause is that getrs! does not ensure length(ipiv) == n before LAPACK call, leading to a segfault.
  2. The secondary cause is that MultiScaleArrays.jl (or one of its dependents) is utilizing LU(factor, ipiv, info) with incompatible sizes for factor and ipiv, which, together with 1. above, causes a segfault.

Fix:

  1. Implement a check in getrs! and raise DimensionMismatch if length(ipiv) != n.
  2. Note: A fix in the wrapper LU(factor, ipiv, info) does not seem feasible as it handles square, thin, and thick matrices with varying ipiv lengths.

Unit test: Test case added to LinearAlgebra/test/lapack.jl to require DimensionMismatch if length(ipiv) != n.

@maleadt maleadt added linear algebra Linear algebra bugfix This change fixes an existing bug labels May 2, 2023
Copy link
Member

@maleadt maleadt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM, thanks for the PR!

@KristofferC KristofferC added the backport 1.9 Change should be backported to release-1.9 label May 2, 2023
@maleadt maleadt merged commit b66f63c into JuliaLang:master May 3, 2023
KristofferC pushed a commit that referenced this pull request May 8, 2023
@KristofferC KristofferC mentioned this pull request May 8, 2023
51 tasks
@KristofferC KristofferC removed the backport 1.9 Change should be backported to release-1.9 label May 28, 2023
kpamnany pushed a commit that referenced this pull request Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug linear algebra Linear algebra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segfault in getrs! during testing of MultiScaleArrays.jl
3 participants