Skip to content

Fix PoolAllocator crash on first allocation - #36

Open
Tidenflow wants to merge 2 commits into
mtrebi:masterfrom
Tidenflow:fix/pool-empty-pop
Open

Fix PoolAllocator crash on first allocation#36
Tidenflow wants to merge 2 commits into
mtrebi:masterfrom
Tidenflow:fix/pool-empty-pop

Conversation

@Tidenflow

Copy link
Copy Markdown

Summary

  • Initialize StackLinkedList::head to nullptr.
  • Return nullptr when StackLinkedList::pop() is called on an empty list.
  • Return a successful exit code after all benchmarks complete.

Problem

After the PoolAllocator initialization was changed to use offset-based lazy allocation, its free list can be empty during the first allocation.

PoolAllocator::Allocate() expects pop() to return nullptr in that case, but StackLinkedList::pop() dereferences head unconditionally. This causes an access violation before the allocator can fall back to allocating a new chunk using the offset.

Verification

Built and ran the project with MinGW on Windows:

cmake -S . -B build -G "MinGW Makefiles"
cmake --build build
build\main.exe

Initialize the intrusive free-list head and return nullptr when no recycled pool chunks are available, preserving lazy O(1) pool initialization.
Return zero after every allocator benchmark completes successfully.
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