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

lac/scalapack.cc: fix an out-of-bounds write that leads to a double free #15600

Merged
merged 2 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/news/9.4.0-vs-9.5.0.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,13 @@ inconvenience this causes.
<h3>Specific improvements</h3>
<ol>

<li>
Fixed: An out-of-bounds write due to an insufficiently sized buffer in
the Scalapack wrappers has been fixed.
<br>
(Matthias Maier, 2023/07/03)
</li>

<li>
Fixed: With some compilers, calling Threads::Task::Task() with a
function object that ends with an exception lead to a segmentation
Expand Down
14 changes: 12 additions & 2 deletions source/lac/scalapack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1592,8 +1592,18 @@ ScaLAPACKMatrix<NumberType>::eigenpairs_symmetric(
int liwork = -1;
NumberType *eigenvectors_loc =
(compute_eigenvectors ? eigenvectors->values.data() : nullptr);
work.resize(1);
iwork.resize(1);
/*
* According to the official "documentation" found on the internet
* (aka source file ppsyevx.f [1]) the work array has to have a
* minimal size of max(3, lwork). Because we query for optimal size
* (lwork == -1) we have to guarantee at least three doubles. The
* necessary size of iwork is not specified, so let's use three as
* well.
* [1]
* https://netlib.org/scalapack/explore-html/df/d1a/pdsyevx_8f_source.html
*/
work.resize(3);
iwork.resize(3);

if (all_eigenpairs)
{
Expand Down