Repository navigation
Conversation
Between GetPooledAllocator and AddLocal, the allocator is neither pooled nor registered, so a collection in that window does not reset it. The thread then allocates from holes that the collection may have handed out again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 28, 2026
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.
When a thread registers,
RegisterCurrentThreadtakes aLocalAllocatorfrom the pool inGetPooledAllocator, which holdsgThreadStateChangeLockonly for that step.AttachThreadthen callsAddLocal, which takes the lock again. In between, the allocator is neither in the pool nor inmLocalAllocs.A collection resets every registered allocator at the end of
Markand every pooled one inClearPooledAlloc. An allocator caught in that window gets neither reset. It keeps its holes, the collection may reclaim those blocks for other allocations, and the newly attached thread then allocates over live objects.The fix calls
Reset()at the start ofAttachThread. That only drops the allocator's current holes, so the thread starts with a fresh allocation region.This is easy to hit when threads attach and detach very often. hxcpp_luv_io's
Work.queueregisters the libuv worker thread withSetTopOfStack(&top, true)and unregisters it withUnregisterCurrentThread()for every work item. hxcoro'sLuvDispatchersends every dispatch throughWork.queue. With that dispatcher, about 25% of hxcoro's C++ test runs on Windows crashed with access violations in unrelated objects (6 of 30). With this change, there were no access violations in 60 runs.🤖 Generated with Claude Code