Repository navigation
title_page_watch: no endless alias walk, mark() covers watched parts, no end wraps (RT-TITLE-PAGE-WATCH-BOUNDS) - #2546
Conversation
… no end wraps (RT-TITLE-PAGE-WATCH-BOUNDS) From kevincommits' Finding 19 on ProjectLeonida#1608 (item 2), in runtime/src/title_page_watch.h: - title_page_aliases::for_each_in walked 64 KiB pages until `end`; with end near UINTPTR_MAX (title_memory_map::changed()'s whole range) the page wrapped to 0 and the walk never ended. It now counts the pages, and a range with more pages than there are aliased pages looks through the aliased set instead. - title_write_watch::mark rounded `to` up with a wrap to 0 (the mark was dropped) and only checked whether the range's first page was watched. It now saturates like title_memory_map::changed, and marks every write-watched part of the range through for_each_in (gathered before the journal's lock; more than 16 parts or kKeep pages mark everything). - title_write_watch::add, kernel_writes::begin_write and hold, and title_texel_writes::note saturate their end at UINTPTR_MAX instead of wrapping; read_file_scatter counts its pages in 64 bits. New CPU test title_page_watch_bounds_test (address arithmetic only): on main its first check hangs (caught by a 5 s limit), and with that case left out 6 of the other 7 checks fail; all 10 pass with the fix. read_file_scatter's count has no test (it would need a million-segment read). AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
#2546 | head aaff683 (merged cleanly with main 02f71cc) | Audited |
lixonik
left a comment
There was a problem hiding this comment.
Reviewed the diff and tested merged onto main (493867366) with Ninja Release (MSVC).
Saturating top-of-address-space bounds and fixing page counting in for_each_in (title_page_watch.h) cleanly avoid wrap-around edge cases, and the new bounds tests plus existing watch/memory-map suites all pass.
Tests run
ctest --output-on-failure -R "^(title_page_watch_bounds|title_write_watch|title_write_watch_on|title_memory_map)$": 4/4 passed (title_memory_map0.03 s,title_write_watch0.02 s,title_page_watch_bounds0.03 s,title_write_watch_on0.00 s).
AI-assisted (Antigravity, Gemini).
timbot103
left a comment
There was a problem hiding this comment.
Static audit of aaff683f3 against 48bae6cad. Please fix the alias ordering before merging.
runtime/src/title_page_watch.h:232emits sparse alias hits in hash-set order, butruntime/shims/d3d12_vulkan_device.cpp:1211binary-searches the resulting list. A missed hit releases an active guard entry and rebuilds it in the same refresh. Please sort the list before searching and cover guard retention across successive refreshes.runtime/src/title_page_watch.h:631andruntime/src/title_page_watch.h:645can still overflow on a synthetic[0, UINTPTR_MAX)overlap. Use1 + (span - 1) / kPagefor a nonempty span. Atruntime/src/title_page_watch.h:229andruntime/src/title_page_watch.h:623, validate the original endpoints before rounding so empty or reversed ranges do nothing.
AI-assisted.
|
On I inserted three synthetic aliases in a nonascending order and scanned a range with more pages than aliases. Main returned a sorted list, and the same An empty interval wholly inside a single aliased page gave one callback on both builds. The PR also accepted a synthetic whole-address-space watch record, but AI-assisted. Codex (GPT-6). |
|
Verified by OreoFR — FAILS (diff read)
AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR. |
Package RT-TITLE-PAGE-WATCH-BOUNDS: item 2 of @kevincommits' Finding 19 on #1608 (#1608 (comment)). Thank you for the find. Claim: #1608 (comment).
What changes (
runtime/src/title_page_watch.h)title_page_aliases::for_each_inalways ends.va < end; va += kPageSize. Whenendis nearUINTPTR_MAX(the whole rangetitle_memory_map::changed()reports) and a page is aliased,vawrapped to 0 and the walk never ended.update_aliasedind3d12_vulkan_device.cpp) does not depend on the order.title_write_watch::mark.toup wrapped to 0 near the top of the address space, so the mark was dropped. It now saturates, astitle_memory_map::changeddoes.contains(from), so a range that starts before a reservation marked nothing. It now marks every write-watched part of the range throughfor_each_in.kKeeppages in all, every reader takes all of its pages as written, as before.title_write_watch::add,kernel_writes::begin_writeandhold, andtitle_texel_writes::notecap their end atUINTPTR_MAX. Before,begin + bytescould wrap, andfor_each_pinthen never found the pin.read_file_scattercounts its pages in 64 bits. Before, abytesvalue near 4 GiB rounded to 0 pages in aDWORD.Tests
New
title_page_watch_bounds_test(CPU only). It does address arithmetic only: nothing is mapped or touched at the addresses it uses.[top - 8 pages, UINTPTR_MAX): the walk ends and finds exactly the two aliased pages in range.mark(base - 1 page, base + 1 page)marks the reservation's first page, and not the unwatched page before it.addof a reservation running past the top keeps it, andmark(..., UINTPTR_MAX)marks its pages.begin_writeandholdof[UINTPTR_MAX - 0xfff, +0x2000)give pins thatfor_each_pinfinds.notepast the top is kept as[begin, UINTPTR_MAX).On main, the first check hangs. The test runs that walk on a thread with a 5 s limit and reports it as a failure. With that case left out, 6 of the other 7 checks fail on main. With the fix, all 10 pass.
read_file_scatter's count has no test, because it would need a read with a million segments.Nearby tests pass 16/16:
ctest -R "title_page_watch|title_write_watch|title_memory_map|kernel_writes|geometry_views|xmem|title_va".gta6rt_d3d12_combuilds.Profile M: RTX 4070 SUPER, Windows 11, Ryzen 7 9800X3D, MSVC RelWithDebInfo. The full suite was not run because a boot was running.
git diff --checkandscripts/check_no_game_data.pyare clean. No open PR touches this file. No game files used.AI-assisted (Claude Code).
🤖 Generated with Claude Code