Skip to content

[GR-74145] C API raw allocation fixes and debugging helpers.#693

Merged
graalvmbot merged 6 commits intomasterfrom
tim/capi-raw-allocation-fixes-and-debugging
Mar 17, 2026
Merged

[GR-74145] C API raw allocation fixes and debugging helpers.#693
graalvmbot merged 6 commits intomasterfrom
tim/capi-raw-allocation-fixes-and-debugging

Conversation

@graalvmbot
Copy link
Collaborator

No description provided.

timfel added 6 commits March 17, 2026 10:37
Correct GraalPy-specific raw allocator bookkeeping in obmalloc.c by charging only the realloc size delta, rolling back reserved bytes when malloc/calloc/realloc fail, and keeping the tracked native-memory total consistent with the actual libc allocation outcome. This fixes a real regression in GraalPy’s custom allocator path while preserving the existing diagnostic work for the NumPy periodic corruption investigation.
Teach GraalPy's raw native allocator to stamp each allocation with a fixed header magic and to verify that header on realloc and free before trusting the recorded size. This keeps the fast path lightweight, aborts immediately on corrupted or foreign headers, and makes allocator misuse fail at the point where the bad pointer first re-enters obmalloc rather than later in libc free().
Add two experimental GraalPy expert options that are threaded into the native C API option bitmask to enable heavier allocator debugging only when requested. With these options enabled, obmalloc can poison freed raw-allocation blocks and record a lightweight rolling history of raw allocation sites, while keeping the new diagnostics off the default path unless an investigation explicitly turns them on.
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Mar 17, 2026
@graalvmbot graalvmbot closed this Mar 17, 2026
@graalvmbot graalvmbot merged commit bfdd4a7 into master Mar 17, 2026
7 checks passed
@graalvmbot graalvmbot deleted the tim/capi-raw-allocation-fixes-and-debugging branch March 17, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants