Repository navigation
Conversation
|
Verified on Windows 11 (MSVC 19.44 / Ninja) at
|
Kam471
left a comment
There was a problem hiding this comment.
Reviewed head 85ee375f54d33cab677a25683e9210f4451772be. Windows 11 26200, MSVC 19.44.35207, Ninja, RelWithDebInfo, LEONIDA_VK_DEVICE='RTX 5070 Ti'.
Counts:
loader: 1/1 passed, 87 checks / 0 failed (includes the newa failed map releases its range and preferred base for a corrected retry)pe_loader: 1/1 passed, 79 checksrun_tiny_gdk_load: 1/1 passedrun_tiny_atexit: 1/1 passed, 8 termination paths match the Windows sequencerun_tiny_frame: 1/1 passed on the Vulkan D3D12 devicectest -R "^loader$|^pe_loader$|^run_tiny_frame$|^run_tiny_gdk_load$|^run_tiny_atexit$": 5/5 passed
Red baseline: reverting only runtime/src/pe_loader.cpp to its parent gives 87 checks / 1 failed, a failed map ...: map_retry.dll: preferred base is taken and the image has no relocations, so the new test does catch the bug.
Rollback path beyond the PR test: I temporarily added (not part of the review) a VirtualQuery assertion to the new test and a second case that fails inside initialize_tls (inverted TLS template) after by_name_ publication. Both passed: the failed section map's preferred range is MEM_FREE, and the TLS failure leaves modules() empty, find_address() false, the range MEM_FREE, and a corrected retry reclaims the preferred base. 88 checks / 0 failed; the worktree was restored afterwards.
Static check: m->base is only assigned by base_reservation::commit_reserved or VirtualAlloc, and both are released with VirtualFree(..., MEM_RELEASE), so the catch cannot unmap memory it did not map. Reserving order_ and ranges_ before publication makes the post-TLS pushes non-throwing.
Verdict: LGTM, ready to merge. Non-blocking nits: lines 1195-1236 of pe_loader.cpp keep the pre-try indentation (the relocation block is now inside it), and the PR's own test does not cover the initialize_tls failure path that the new inner try/catch handles (it works when exercised).
|
Checked head New data: I mutated each rollback line in
The injected record failure does reach No defect reproduced. This is a coverage gap in the new test, not a failing case. Of the other open PRs touching |
|
Tested 5b2fdcd merged with main 561b65a on Windows (native, MSVC 14.51 / VS 18, Ninja, RelWithDebInfo, built from a
Negative control (weak): with |
|
Thanks for the mutation review. I added the two requested checks at f73564a: after the injected record failure, the test now verifies that the global TLS owner is retired and the loading thread's helper slot is restored, alongside the existing worker-thread check. The same 89 loader checks and three focused CTests pass locally; the PR description now names this head. AI-assisted. |
Claimed in the coordination tracker.
Why
Loader::map_imagepublished an allocation, module and address range before section, relocation and export validation finished. A failed map remained inmodules()andfind_address()and held its preferred address until Loader destruction, so a corrected non-relocatable image at the same path could not be retried.Change
Prepare and validate the image before publishing it. On failure, release a standalone allocation or decommit an inherited base reservation, and remove any TLS state installed on the current or existing threads. Import binding and later initialization are separate paths.
Regression coverage
Three synthetic Windows CPU cases cover distinct cleanup rules: ordinary failed map and same-path retry; failed map inside an inherited reservation and recommit; injected existing-thread TLS record failure, including verification that the worker and loading thread TLS slots are restored and the global owner is retired before retry. The injection hook is compiled only into
loader_test.Validation
f73564a7:loader_test89 checks, 0 failed; focusedloader,pe_loader,pe_loader_boundsCTest 3/3 passed. The preceding test-only head also passed 20 repeatedloaderruns.scripts/check_no_game_data.pyon changed source/test files andgit diff --checkpassed. Windows 11 CPU with clang-cl 21.1.8; no game files or GPU used.Overlap
Merged #2954 and #3667 intentionally retain failed mappings/ranges until Loader destruction. #3981 handles later initialization failures. This PR covers map-time rollback.
AI-assisted: yes
Checklist