Fix ACA workspace allocation for strain and max_iter=0 edge case#53
Merged
maresb merged 4 commits intocutde-org:mainfrom Mar 6, 2026
Merged
Fix ACA workspace allocation for strain and max_iter=0 edge case#53maresb merged 4 commits intocutde-org:mainfrom
maresb merged 4 commits intocutde-org:mainfrom
Conversation
When max_iter=0, no ACA terms should be produced and the result should be a zero-rank approximation.
When max_iter is 0 (either passed explicitly or due to tiny blocks), the ACA loop never executes but n_terms was incorrectly set to 1. This caused the Python post-processing to read uninitialized buffer memory. Now correctly sets n_terms to 0 when no iterations run.
…h-52) With vec_dim=6 and n_src > 2*n_obs, the undersized workspace causes a heap buffer overflow (SIGABRT on Linux, silent corruption on macOS).
The 3rd and 4th terms had swapped multipliers: used 3*n_cols and vec_dim*n_rows instead of vec_dim*n_cols and 3*n_rows. This matched the kernel layout for displacement (vec_dim=3) but was undersized for strain (vec_dim=6) when n_cols > n_rows.
b740a22 to
fbcf264
Compare
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.
Summary
fworkspace_per_blockallocation for strain ACA (vec_dim=6) with asymmetric blocks wheren_src > 2 * n_obs(fixes Bug: fworkspace allocation in aca.py undersized for strain (vec_dim=6) with asymmetric blocks #52)n_termsbeing set to 1 instead of 0 whenmax_iter=0in the ACA kernel, which caused post-processing to read uninitialized buffer memoryDetails
fworkspace_per_block (gh-52): The Python-side workspace allocation had the
3andvec_dimmultipliers swapped relative to the C kernel layout:For displacement (
vec_dim=3) both expressions are identical, so the bug was invisible. For strain (vec_dim=6), blocks withn_cols > n_rowscaused heap buffer overflow (SIGABRT on Linux, silent corruption on macOS).max_iter=0: When
max_iter=0, the ACA loop never executes butn_termswas set tok + 1 = 1. Now correctly returns 0 terms.Made with Cursor