Skip to content

Free leaked _get_dims allocation in dot/diag/cumsum wrappers#24

Merged
sigilante merged 1 commit into
mainfrom
sigilante/get-dims-leak-fix
May 30, 2026
Merged

Free leaked _get_dims allocation in dot/diag/cumsum wrappers#24
sigilante merged 1 commit into
mainfrom
sigilante/get-dims-leak-fix

Conversation

@sigilante
Copy link
Copy Markdown
Collaborator

Summary

_get_dims u3a_mallocs a c3_d* and returns it. Three call sites in each jet file used _get_dims(shape)[0] and discarded the returned pointer, leaking a buffer (sized to the array's rank) on every call to the affected wrappers (dot/trace, and the cumsum/diag-family wrappers). The two other call sites already capture and free the pointer.

Fix

At each leaking site, capture the pointer, read [0], then u3a_free it — across all three jet files:

  • lagoon/vere/noun/jets/i/lagoon.c
  • lagoon/vere64/noun/jets/lagoon.c
  • maroon/vere/noun/jets/i/lagoon.c

Pure leak fix; no behavioral change.

🤖 Generated with Claude Code

_get_dims malloc's a c3_d* and returns it. Three call sites used
_get_dims(shape)[0] and discarded the pointer, leaking a buffer
(proportional to array rank) on every call to the affected wrappers.
The other two call sites already capture and free the pointer.

Capture the pointer, read [0], and free it at all three sites in each
of the three jet files.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sigilante sigilante merged commit 8454ab1 into main May 30, 2026
@sigilante sigilante deleted the sigilante/get-dims-leak-fix branch May 30, 2026 14:48
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.

1 participant