mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:45:53 +01:00
[PR #1739] runtime: guard DescriptorTable 9-way collision, read_slots width, and change-tracking OOM #1751
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#1751
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/1739
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/descriptor-table-guards📝 Commits (1)
f41be19runtime: guard DescriptorTable 9-way collision, read_slots width, and change-tracking OOM📊 Changes
2 files changed (+187 additions, -12 deletions)
View changed files
📝
runtime/src/descriptor_table.h(+24 -12)📝
runtime/test/descriptor_table_test.cpp(+163 -0)📄 Description
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.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.