Skip to content

Fix workspace size in ReLAPACK sytrf/hetrf - #5966

Merged
martin-frbg merged 1 commit into
OpenMathLib:developfrom
Ka-zam:relapack-sytrf-workspace
Aug 8, 2026
Merged

Fix workspace size in ReLAPACK sytrf/hetrf#5966
martin-frbg merged 1 commit into
OpenMathLib:developfrom
Ka-zam:relapack-sytrf-workspace

Conversation

@Ka-zam

@Ka-zam Ka-zam commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

The ?sytrf/?hetrf routines size their workspace as n*(n/2) and report that from the lWork = -1 query, but the top level recursion addresses Work as an n by xREC_SPLIT(n) matrix with leading dimension n. xREC_SPLIT rounds up, so whenever xREC_SPLIT(n) > n/2 the routine writes past the end of the buffer it asked for — silently wrong factorization and a corrupted heap.

For zsytrf, ZREC_SPLIT(500) = 252 against the 250 columns the buffer holds.

Repro: build with BUILD_RELAPACK=1 RELAPACK_REPLACE=1, query lWork, allocate exactly that, call zsytrf. Before this patch 114 of 241 sizes in [64,1024] return garbage; sweeping every n in [100,600] aborts on heap corruption. After, a workspace-query/factorize/solve residual check over 12 routines x every n in [64,400] passes 4044/4044.

Sizes the workspace with the same xREC_SPLIT the recursion uses. Affects all 12 variants.

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
Ka-zam force-pushed the relapack-sytrf-workspace branch from fc9cc59 to 4a4cd8f Compare August 8, 2026 13:22
@martin-frbg

Copy link
Copy Markdown
Collaborator

Great catch, thanks.

@martin-frbg martin-frbg added this to the 0.3.35 milestone Aug 8, 2026
@martin-frbg
martin-frbg merged commit 9ff4623 into OpenMathLib:develop Aug 8, 2026
106 checks passed
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

Successfully merging this pull request may close these issues.

2 participants