arena_size: a negative LEONIDA_ARENA_MB clamps to the 16 MiB floor, not the 4095 MiB maximum (ARENA-NEGATIVE-MB) #923
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!923
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/923/head"
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?
@TuroYT on GitHub · 2026-11-24 15:12 UTC · original
TuroYT:fix/arena-negative-mb→main· +7 −1 · 2 files · 1 commits · merged 2026-11-24 21:26 UTCClaimed in the coordination issue as: ARENA-NEGATIVE-MB (#14)
What was wrong
runtime/src/arena_size.h:63parsedLEONIDA_ARENA_MBwithstd::strtoull. A negative number wraps to a hugeunsigned value, so
std::clampreturned the 4095 MiB maximum. The header comment documents a clamp to 16..4095 MiB,and a negative number should reach the 16 MiB floor.
Reproduction on
origin/main(g++ 16,-std=c++20 -fsanitize=address,undefined, a probe callingdecide_arena_sizewith an emptyArenaLimits):What changed
runtime/src/arena_size.h: parse withstd::strtolland clamp as a signed value before converting toVkDeviceSize. Negative text now reaches the 16 MiB floor. Every other input keeps its result.runtime/test/arena_size_test.cpp: three new checks inrequest_without_limits:"-5"gives 16 MiB,"-99999999999999999999"gives 16 MiB,"99999999999999999999"gives 4095 MiB.Tested
g++ -std=c++20 -Wall -Wextra -fsanitize=address,undefined -I runtime/src -I <dir with vulkan/ and vk_video/> runtime/test/arena_size_test.cppthen run the binary: builds with no warnings, prints the summary line, exit 0.clang++: exit 0. It prints three-Wmissing-field-initializerswarnings fromquery_arena_limits(lines 34 to 36), which this change does not touch.origin/mainheader: fails withline 32: decide_arena_size("-5", none).bytes == 16 * MiB, exit 1.-5,-1,-0,-5,-99999999999999999999andabcgive 16 MiB;99999999999999999999and99999give 4095 MiB;+20gives 20 MiB;0x20gives 16 MiB.python3 -I scripts/check_no_game_data.py runtime/src/arena_size.h runtime/test/arena_size_test.cpp: exit 0.git diff --check: clean.Not tested
arena_sizeon Windows.cteston Linux for the whole runtime tree (only the single test file was built and run).runtime/shims/d3d12_vulkan_device.cpp.origin/mainheader ran one at a time through the probe. The test stops at its firstfailing check (line 32), so the huge-negative check was not reached by the test binary on the unfixed header.
AI-assisted (Claude Code).
strtoull("-5") wraps to 2^64-5, so decide_arena_size clamped it to the 4095 MiB maximum. strtoll clamps "-5" and "-99999999999999999999" to the 16 MiB floor, as the header comment documents. Adds checks for "-5", the huge negative and the huge positive to arena_size_test. Other inputs keep their results.@KernelSmoker on GitHub · 2026-11-24 15:17 UTC · original · approved these changes
Reviewed exact head
49e6392c9e6ee45cfce8ef7b690aaa7fc223ce0d. ParsingLEONIDA_ARENA_MBas signed prevents negative values from wrapping throughstrtoull; clamping occurs in MiB bounds before conversion toVkDeviceSize, and overflow values still clamp to the documented floor/ceiling. The added negative and overflow cases cover the regression. I built and ranruntime/test/arena_size_test.cppin the Fedora 45 tool container using GCC 16 with-std=c++20 -Wall -Wextra -Werror -pedantic; it passed and printed the expected summary. I could not independently link the sanitizer variant because this tool image lackslibubsan; this is an environment limitation. No GPU/game data used.@QemmHD on GitHub · 2026-11-24 21:26 UTC · original
Merging.
Why merged: ARENA-NEGATIVE-MB: LEONIDA_ARENA_MB is parsed with strtoll, so a negative value clamps to the 16 MiB floor instead of wrapping around to the 4095 MiB maximum. KernelSmoker approved this exact head.
Why it's good: A 3-line parse change. arena_size passes both plain and under validation.
Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Merged alone onto main
66d4f5aa3, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative of this batch (13 PRs) on main0b45fdc21: the repo-consistency set gives 573 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 314/316 with the same 11 skips. The only failures are main's: d3d12_depth_resolve (pre-existing) and d3d12_close_parity (the #510 regression, fixed by #1286). All d3d12_* tests under validation show 0 VUIDs. git merge-tree against current main6261ca916: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes.AI-assisted (Claude Code, Claude Opus 5.5).