mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:45:53 +01:00
[PR #520] [MERGED] VULKAN-SCRATCH-ALIGN-OVERFLOW: avoid uint64 overflow when aligning chunk.used #568
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#568
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/520
Author: @xroneyaa
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @ubiquitarianism
Base:
main← Head:fix/vulkan-scratch-align-overflow📝 Commits (1)
aab57e1vulkan_scratch: avoid uint64 overflow when aligning chunk.used📊 Changes
2 files changed (+31 additions, -6 deletions)
View changed files
📝
runtime/src/vulkan_scratch.h(+10 -6)📝
runtime/test/vulkan_scratch_test.cpp(+21 -0)📄 Description
Claimed in the coordination issue as: VULKAN-SCRATCH-ALIGN-OVERFLOW
What and why
In
runtime/src/vulkan_scratch.h,ScratchBuffers::getroundedchunk.usedup to a 256-byte boundary with:When
chunk.used > UINT64_MAX - 255,chunk.used + alignment - 1wraps arounduint64_tandstartbecomes0, passingstart <= chunk.size && bytes <= chunk.size - startand returning offset0inside an already occupied chunk.This computes the alignment padding cleanly (
rem = chunk.used % alignment; pad = rem ? alignment - rem : 0) and checkspad <= chunk.size - chunk.usedbefore formingstart = chunk.used + padand checkingbytes <= chunk.size - start. It also adds a regression case toruntime/test/vulkan_scratch_test.cppverifying aUINT64_MAX - 100byte allocation followed by a16byte allocation spills to a second chunk rather than wrapping to offset0in chunk 1.Tested
vulkan_scratch_testwith MSVC 19.50 / Ninja (0 warnings under/W4)ctest --test-dir runtime/build --output-on-failure -R "^vulkan_scratch$"-> 1/1 Passed (0.01 s)python -I scripts/check_no_game_data.py runtime/src/vulkan_scratch.h runtime/test/vulkan_scratch_test.cpp-> exit 0GPUs tested: n/a (
vulkan_scratchruns CPU-only with fake device procs)AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed (n/a — no translator rule added).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.