Fix workspace size in ReLAPACK sytrf/hetrf - #5966
Merged
Merged
Conversation
xREC_SPLIT rounds up, so n*(n/2) is smaller than the n by xREC_SPLIT(n) workspace the top level recursion addresses whenever xREC_SPLIT(n) > n/2 (n=500 splits 252/248). The routines then write past the end of the buffer they reported from the lWork=-1 query, silently corrupting both the factorization and the heap. Size the workspace with the same xREC_SPLIT the recursion uses.
Ka-zam
force-pushed
the
relapack-sytrf-workspace
branch
from
August 8, 2026 13:22
fc9cc59 to
4a4cd8f
Compare
Collaborator
|
Great catch, thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
?sytrf/?hetrfroutines size their workspace asn*(n/2)and report that from thelWork = -1query, but the top level recursion addressesWorkas annbyxREC_SPLIT(n)matrix with leading dimensionn.xREC_SPLITrounds up, so wheneverxREC_SPLIT(n) > n/2the routine writes past the end of the buffer it asked for — silently wrong factorization and a corrupted heap.For
zsytrf,ZREC_SPLIT(500) = 252against the 250 columns the buffer holds.Repro: build with
BUILD_RELAPACK=1 RELAPACK_REPLACE=1, querylWork, allocate exactly that, callzsytrf. Before this patch 114 of 241 sizes in[64,1024]return garbage; sweeping everynin[100,600]aborts on heap corruption. After, a workspace-query/factorize/solve residual check over 12 routines x everynin[64,400]passes 4044/4044.Sizes the workspace with the same
xREC_SPLITthe recursion uses. Affects all 12 variants.