mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:50:52 +01:00
[PR #1975] runtime: unlock ImageMemoryPool across driver allocations/frees and fix BlockRanges alignment overflow #1981
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1981
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1975
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/rt-image-memory-unlock-alloc-and-overflow📝 Commits (1)
1f1248bruntime: unlock ImageMemoryPool across driver allocations and fix BlockRanges alignment overflow📊 Changes
2 files changed (+111 additions, -21 deletions)
View changed files
📝
runtime/src/image_memory.h(+41 -21)📝
runtime/test/image_memory_test.cpp(+70 -0)📄 Description
Claim:
RT-IMAGE-MEMORY-UNLOCK-ALLOC-AND-OVERFLOW(claim comment#7169137144on #1608).Fixes (
runtime/src/image_memory.h)mutex_acrossallocate_()and failure-pathfree_()inImageMemoryPool::allocate():allocate()heldmutex_acrossallocate_(type, block_bytes)(a 100+ µsvkAllocateMemorykernel call) and across failure-pathfree_(memory)— stalling every concurrent texture allocation,stats()query, andDeferredDeletionQueuerange release, and risking AB-BA lock-order inversion with driver/device locks (release()already unlockedmutex_before callingfree_()).allocate_()andfree_()callbacks run outsidemutex_, with exception-safe cleanup ifstd::make_unique<Block>throws.uint64_twraparound inBlockRanges::allocate()alignment calculation:(piece + alignment - 1) / alignment * alignmentcould wrapuint64_tfor largealignmenton a non-zeropiece.rem = piece % alignment; lead = rem ? alignment - rem : 0).BlockRanges::release():by_offset_.lower_bound(offset)and iterator-based erasure instead of two separate tree lookups, and guards zero-size releases.Verification
CMakeLists.txtchanges).runtime/test/image_memory_test.cppwithallocate_runs_unlocked()(blocks insideallocate_()while verifying another thread completes an existing-block allocation,stats(), andrelease()without deadlocking) plusBlockRangesalignment-overflow (UINT64_MAX,(1<<63)+1,0) and zero-size release tests.image_memory_testcleanly under:clang++ -std=c++20 -O1 -g -fsanitize=address,undefined -Wall -Wextra -Werror -pthreadclang++ -std=c++20 -O1 -g -fsanitize=thread -Wall -Wextra -Werror -pthreadclang++ -std=c++20 -O2 -Wall -Wextra -Werror -pthreadpython3 -I scripts/check_no_game_data.pyon both files andpython3 -I tests/test_text_write_line_endings.py: all passed.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.