Skip to content

Clear deferred-free state when the custom GPU allocator frees a block - #1375

Merged
biochem-fan merged 1 commit into
3dem:ver5.1from
uermel:fix/allocator-stale-deferred-free
Oct 15, 2026
Merged

biochem-fan merged 1 commit into
3dem:ver5.1from
uermel:fix/allocator-stale-deferred-free

Conversation

@uermel

@uermel uermel commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1374.

_free() marks a block free but keeps its freeWhenReady flag and completed readyEvent, which AccPtr::freeDevice() sets on most frees. Since #1369, alloc() can hand that block back out on an exact fit, so the next _freeReadyAllocs() frees it again under its new owner, and the owner's own free then hits a block that was already freed or merged away.

This destroys the event and clears freeWhenReady in _free(), so a free block carries no pending deferred free. The HIP allocator has the same code and gets the same change; only CUDA was tested.

Testing: the command from #1374 on an NVIDIA L40S, with RELION built from 108ef3c (allocator code identical to the current ver5.1), CUDA 12.8 and gcc 12.4. Without this patch it segfaults in CudaCustomAllocator::_free in the first expectation iteration; with this patch the refinement runs through.

🤖 Generated with Claude Code

…3dem#1374)

_free() marked a block free but kept its freeWhenReady flag and its
completed readyEvent, which AccPtr::freeDevice() sets on most frees.
Since 3dem#1369, alloc() can return a free block itself on an exact fit, so
the next _freeReadyAllocs() freed it again under its new owner, and the
owner's own free then hit a block that was already freed or merged away.

Destroy the event and clear freeWhenReady in _free(), so a free block
carries no pending deferred free. The HIP allocator has the same code.

Fixes 3dem#1374

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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