runtime: guard DescriptorTable 9-way collision, read_slots width, and change-tracking OOM #1739
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1739"
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?
Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T10:37:37Z.
Item ID:
RT-DESCRIPTOR-TABLE-GUARDSClaim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7159904197
Summary
Hardens
runtime/src/descriptor_table.h(the bindless set 0, binding 2 T#/S# hash table) against three edge-case bugs:insert_locked()): previously,(occupied_count_ + 1) * 2 > entries_.size()calledgrow_locked()before checking whether all 8 probe slots already held keys with full hashh. Inserting a 9th colliding key into a 16-slot table needlessly doubled capacity (16 -> 32) and setall_changed_ = truebefore throwingstd::length_error. Checking the 8-slot full-hash collision first refuses immediately without mutating capacity or dirty state.read_slots(): wideneddest + std::size_t(i) * 10andentries_[std::size_t(first) + i]so large counts cannot wrap 32-bituint32_tarithmetic.all_changed_:mark(slot)pushed tochanged_slots_after mutatingentries_andoccupied_count_(and before--occupied_count_inerase_locked()). Astd::bad_allocinsidechanged_slots_.push_backleft CPU entries mutated (andoccupied_count_stale on erase) while dropping the dirty slot fromtake_changes(), desynchronizing the GPU descriptor table from the CPU table.reserve_marks(count)now reserveschanged_slots_capacity before mutatingentries_/occupied_count_(and beforemake_probe_slot()relocates a resident), and bothreserve_marks()andmark()are no-ops whenall_changed_is already set (since the nextBindlessSetupload writes the full table).Verification
clang++ -std=c++20 -Wall -Wextra -Werror -O1 -g -fsanitize=undefined runtime/test/descriptor_table_test.cpp -pthread: PASS (0 failures).clang++ -std=c++20 -Wall -Wextra -Werror -O2 runtime/test/descriptor_table_test.cpp -pthread: PASS (0 failures).descriptor_table_test.cppagainst unpatchedmain:runtime/src/descriptor_table.h: FAILS as expected (exit 1ontest_unresolvable_collision_does_not_grow_at_load_threshold).python3 -I scripts/check_no_game_data.py runtime/src/descriptor_table.h runtime/test/descriptor_table_test.cpp: PASS.python3 -I tests/test_text_write_line_endings.py: 3/3 OK.Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T10:37:52Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from ubiquitarianism/leonida. Originally posted by potatoe0100 on 2026-11-25T10:57:20Z.
Windows/MSVC check:
f41be1995merged ontomainbcaa13dad(clean), native Windows 11 Pro 26H2 (build 26300), MSVC 19.44 (VS 2022) RelWithDebInfo + Ninja, NVIDIA GeForce RTX 4060, driver 621.14.descriptor_tablepasses.ctest -j 6: 409 of 409 passed, same asmain.run_gpu_tests.py: 209/263 passed, 53 skipped, identical tomain(the one failure,cs_imgatomic_ext, is onmaintoo).AI-assisted testing (non-developer tester).
Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-25T10:58:27Z.
Review: APPROVED
### Clean-Room & Technical Verification
main(bcaa13dad) is 100% clean with zero merge conflicts.check_no_game_data.pyclean).16 -> 32) and unnecessaryall_changed_dirty flags prior to throwingstd::length_error.read_slots()to 64-bit (std::size_t), safeguarding against 32-bit integer overflow.reserve_marks()before modifyingentries_oroccupied_count_, eliminating CPU/GPU state desynchronization under OOM.all_changed_is already active.runtime/test/descriptor_table_test.cppwith OOM fault injection testing.LGTM! Approved.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T02:51:04Z.
Hi @IlyassRS3, thanks for this pull request. It currently conflicts with
main(conflicting file(s):runtime/src/descriptor_table.h,runtime/test/descriptor_table_test.cpp), so it carries theneeds rebaselabel. CONTRIBUTING.md asks authors to rebase their branch onmain; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:53:59Z.
Verified by OreoFR
c1ecf04ed+ PR headf41be1995(tested atf41be1995, head is nowb6b41e4c5)AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T23:25:45Z.
Windows 11 Native Verification Report (
b6b41e4c51merged ontoorigin/mainadfb3821a2)origin/main(adfb3821a2) and clean in a 5-PR runtime batch merge.10.0.26200, x64), MSVC19.44.35228.Diff Audit (
2files,+183/-11)runtime/src/descriptor_table.h:read_slots64-bit indexing (descriptor_table.h:285-289): promotesfirst + iandi * 10tostd::size_t, preventing 32-bituint32_toverflow when serializing>= 429,496,730slots (>= 2^29capacity tables).descriptor_table.h:369-384): checks whether all 8 probe slots already hold distinct keys with the exact same 32-bit hash before(occupied_count_ + 1) * 2 > entries_.size()triggersgrow_locked(), preventing futile table doubling andall_changed_invalidation at the 50% load threshold.descriptor_table.h:312-319, 357, 386, 419): skipschanged_slots_.push_backwhileall_changed_is already set, and callsreserve_marks(...)prior to mutatingentries_oroccupied_count_across insert, replace, 8-probe resident relocation (reserve_marks(2)), and erase sostd::bad_alloccannot leave CPUentries_and GPU dirty tracking out of sync.runtime/test/descriptor_table_test.cpp: addsScopedAllocFailureoperator newOOM fault-injection tests, 50%-load 9-way collision tests (fnv1aandfnv1a_fmix32), andall_changed_slot-tracking elision/resumption checks.Red -> Green Verification
origin/mainadfb3821a2):#1739'sruntime/test/descriptor_table_test.cppcompiled againstorigin/maindescriptor_table.hexited1:assertion failed: table.capacity() == 16 && table.size() == 8(test_unresolvable_collision_does_not_grow_at_load_threshold, whereorigin/maingrew capacity from16to32and setall_changed_before throwingstd::length_error).#1739+origin/main):descriptor_table_test.exe(/O2 /EHsc /W4 /permissive- /utf-8,0new warnings):descriptor_table_test: all tests passed (0 failures)(0.07 s,rc=0).Verdict: PASS — ready to merge.
AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T15:42:19Z.
Merged. Tested by @zmasi on head
b6b41e4c5(CPU only (Windows 11, MSVC)): red: PR descriptor_table_test vs main header fails capacity()==16 (grows to 32); green all tests pass. The CI jobs that are red on this head were also red on main at the time of the run. Thanks @IlyassRS3!AI-assisted: yes