Skip to content

Port memory leak and bad free fixes from superlu PR #180 to base files - #3

Merged
xiaoyeli merged 1 commit into
masterfrom
claude/epic-rubin-j04ke9
Oct 18, 2026
Merged

xiaoyeli merged 1 commit into
masterfrom
claude/epic-rubin-j04ke9

Conversation

@xiaoyeli

Copy link
Copy Markdown
Owner

Summary

Mirrors xiaoyeli/superlu#180 (Fix memory leaks and bad frees) in the precision-generic templates, so that future extractions of the s/d/c/z sources carry the same fixes.

  • SRC/xgsisx.base, SRC/xgssvx.base: free the MC64 permutation, the permuted matrix AC and the SLU_NR copy AA on the early returns taken for the lwork == -1 memory query and for a singular factorization.
  • EXAMPLE/xlinsolx.base, xlinsolx1.base, xlinsolx2.base, xlinsolx3.base: release the L and U SuperMatrix stores when the factors live in a user-supplied work[] array. xlinsolx2 no longer calls Destroy_SuperNode_Matrix / Destroy_CompCol_Matrix on work[] storage.
  • TESTING/xdrive.base: always destroy the factors xgssv allocated, free the previous factors before xgssvx refactors with DOFACT or SamePattern, and destroy the work[] stores inside the loop instead of once at the end.

The AddressSanitizer CI job added by the upstream PR has no counterpart in this repository and is not included.

Verification

The extract tool was not available, so the templates were checked by diffing each template's change, with @(pre) substituted by d, against the upstream PR's diff of the corresponding double-precision file. Six of seven match byte for byte; TESTING/xdrive.base differs only in a comment, where the upstream PR itself used "allocated the factors itself" in ddrive.c and "allocated the factors" in sdrive.c, cdrive.c and zdrive.c. The template uses the latter wording.


Generated by Claude Code

Mirror xiaoyeli/superlu#180 (Fix memory leaks and bad frees) in the
precision-generic templates so future extractions carry the fixes:

- SRC/xgsisx.base, SRC/xgssvx.base: free the MC64 permutation, the
  permuted matrix AC and the SLU_NR copy AA on the early returns taken
  for the lwork == -1 memory query and for a singular factorization.
- EXAMPLE/xlinsolx*.base: release the L and U SuperMatrix stores when
  the factors live in a user-supplied work[] array; xlinsolx2 no longer
  calls Destroy_SuperNode_Matrix/Destroy_CompCol_Matrix on work[]
  storage.
- TESTING/xdrive.base: always destroy the factors xgssv allocated, free
  the previous factors before xgssvx refactors with DOFACT or
  SamePattern, and destroy the work[] stores inside the loop instead of
  once at the end.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VjnVBdsXEM3c41ssQ3hFAM
@xiaoyeli
xiaoyeli merged commit da9516f into master Oct 18, 2026
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