tools/address_guard: match runtime 48-bit wraparound spans and header last_module field #2420
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2420
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/address-guard-wraparound-parity"
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 successfully merged and closed
Claimed in the coordination issue as: TOOLS-ADDRESS-GUARD-WRAPAROUND (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7208856827)
What and why
tools/address_guard.py:table_wordspreviously skipped any span withend <= startand iterated a single linear page range, silently dropping valid 48-bit wraparound spans (such as((-0x2000) & MASK48, 0)already passed intests/semantic/test_address_guard.py, or(-0x1000, 0x1000)crossingheap_baseas tested inruntime/test/address_guard_test.cpp).runtime/src/address_guard.h(AddressGuardTable::assign): skip empty spans mod2^48and mark wrapping spans as two runs[first, max_page]and[0, last]using chunk-level bit-range marking (_mark_pages, also making multi-GiB spans fast).last_module=0parameter toheader()matchingAddressGuardHeader::last_moduleinruntime/src/address_guard.h.tests/test_address_guard.pyand extendtests/semantic/test_address_guard.pywith wraparound assertions.Tested
python -I tests/test_address_guard.py -v: 7/7 OK (wraparound assertions fail on unpatchedmaind1dff7949).python -I tests/semantic/test_address_guard.py -v: 12/12 OK.address_guard_test.exe(MSVC 14.44 RelWithDebInfo):address_guard_test: ok.python -I scripts/run_address_guard_gpu_test.py --build <build-dir>:PASS (guard on)andPASS (guard off).python -I scripts/check_no_game_data.py+tests/test_text_write_line_endings.py: exit 0.GPUs tested: NVIDIA GeForce RTX 3060 12 GB, NVIDIA driver 617.14, Windows 10 (
run_address_guard_gpu_test.py)AI-assisted: yes (Antigravity gemini-4-neon)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a — not a translator rule)Approving. Checked on 1524a0913, which merges cleanly onto main.
tests/test_address_guard.py: 7 passed.tests/semantic/test_address_guard.py: OK. As a negative check I ran both against main'stools/address_guard.py: 5 failures in the new file and 3 in the semantic one, so the tests do pin the wraparound andlast_modulechanges.Compared with
runtime/src/address_guard.h: the header field order matchesAddressGuardHeader(refused, last_module, last_refused), and the wrap handling is the same asassign(), first/last 48-bit page numbers and two runs throughkMask48 >> 12when first > last._mark_pagesalso mirrorsmark()word by word, and the boundary test covers it.One small difference, not a blocker:
assign()skips a span only whenend == startas 64-bit values, whiletable_wordsskips it when(end - start) & MASK48 == 0. They differ only for a span given as mixed forms, e.g.(-0x2000, (-0x2000) & MASK48)intest_empty_spans_produce_only_empty_and_full_blocks. Python calls that empty; the C++ (if it were ever handed a sign-extended start and a masked end) would see first > last and mark the whole 48-bit space. The Python reading is the sensible one and the runtime builds its spans in one form, so this is only about the docstring's "matching" claim. Either note it there, or make the runtime mask both ends before comparing.#2420 | head 1524a0913a75dccb3f770c47d73bac2cf745b1f6 (merged cleanly with main 33db04a70) |
python -I tests/test_address_guard.py && python -I scripts/run_semantic_tests.py -p test_address_guard.py tests/semantic| red on main:FAILED (failures=4, errors=1)(TypeErroronlast_moduleand3 != 4allocated level-2 blocks on 48-bit wraparound spans) and semanticFAILED (failures=3)| green on PR+main:7 tests OKand12 tests, 0 failed| Windows 11, Python 3.12.10 | AI-assisted: yesAudited
header,_mark_pages, andtable_wordsintools/address_guard.py(48-bitMASK48wraparound splitting[first, max_page]+[0, last], word-slice bit marking, andlast_moduleheader field matchingruntime/src/address_guard.h). Also passedtests/test_ci_registration.py(18 OK),tests/test_text_write_line_endings.py(3 OK),tests/test_runner_calls_all_tests.py(3 OK), andscripts/check_no_game_data.pyon the merged tree.Merged, thank you @Andretuta! This PR (tools/address_guard: match runtime 48-bit wraparound spans and header last_module field) was checked by zmasi or sodove and then by our own local run of its tests with main merged in, and it passed cleanly, so it went in with its reviewed batch.
AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.