Repository navigation
Conversation
|
AI-assisted. Cause of "88 of 64" in the unprotected control: with --suspend-others 0 another thread can re-patch the hook byte before the stepping thread has run the original instruction, so that thread traps again at the same address. The entry hook registered the same call twice (same thread, same stack slot), and the return wrote one line per registration. Replaying that bookkeeping with 24 re-trapped calls out of 64 gives 88 lines with the old logic and 64 with the fix. Changes in the new commit: pending returns now live in Linux: startup_hook_window logic, py_compile, docs_links_check, bidi_controls_check pass. Windows not run by me. Node command: ctest --preset dev -R 'startup_hook|startup_launch' (Debug and /O2). PR stays Draft. |
|
AI-assisted. Pushed 3cfa172 for the Windows Server 2025 failure of startup_hook_overlap (windows=132 unprotected=1 timeouts=0). Cause: a thread that has called ExitThread stays in the debugger's thread list until its exit event is read. OpenThread still succeeds on it, but SuspendThread/GetThreadContext fail with access denied, and hold_thread returned FAILED, so the window counted it as unprotected although it runs no code. The hold is now classified after the failure by a pure function (hook_window.classify_hold): GONE when GetExitCodeThread != STILL_ACTIVE (or the handle is already signaled, for a thread that is terminating and has no exit code yet), FAILED when the thread is alive and could not be suspended. A live unsuspendable thread still counts as unprotected, and the test still requires unprotected == 0. Ruled out by reading: a thread created after the list is read (CREATE_THREAD held at its event), an already suspended thread (nested count is not an error, only 0xFFFFFFFF is), a reused or closed handle (a fresh handle per hold, threads dropped from the list on exit), the owner itself (excluded from the others). Linux checks: py_compile, startup_hook_window (new GONE/FAILED cases; the old module has no classifier), docs_links_check, bidi_controls_check, preflight. The Win32 debugger race cannot be run on Linux, so it is not verified here. Windows: ctest --preset dev -R 'startup_hook|startup_launch' (Debug and /O2). |
|
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207) at commit
|
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3cfa1726b4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Tested on Windows 11 26200, MSVC 19.42, RTX 4070 Ti (driver 621.35) at 3cfa172: AI-Assisted |
86d81f9 to
6df8cf0
Compare
|
Thanks @SimSalabimse for verifying on Windows 11 26200 / MSVC 19.42! Rebased onto current |
|
Thanks @SimSalabimse: that is the hardware pass (RTX 4070 Ti, 64/64 opens traced against 12 lost by the control) on top of our Windows Server 2025 run. No change to the head is needed. |
|
Ran this branch on a Windows 11 client (build 26300, MSVC 14.51, Python 3.14), commit 86d81f9 (same hook code as the rebased head 6df8cf0).
Cost: 2 x 2000 serial opens took 7.1 to 8.0 s on main and 12.5 to 13.3 s at 2fabc90 (three runs AI-assisted. |
|
Thanks @RenzoWit35, great catch on the Win11 26300 Verified on Windows Server 2025 at |
c0816fa to
ecbbf3e
Compare
|
Retested at ecbbf3e on Windows 11 26200, MSVC 19.42, RTX 4070 Ti (driver 621.35): startup_launch, startup_hook_window and startup_hook_overlap pass in both presets (ctest exit 0 for dev and release). startup_hook_overlap traced 64/64 opens with the window on both presets; the unprotected control lost 21 opens on dev and 30 on release. So the NtSuspendThread path holds on Win11 as well. AI-Assisted |
|
Independent integration check on Windows 11 build 26300.9711, Python 3.13 / MSVC 19.44 Debug: combined main 8f43802, #1251 at ad94c95, and #1408 at ecbbf3e (plus the independent UTF-8 storage change #1551). The merge needs one semantic resolution in The combined source-built map overlap control reports 64 opens / 64 traces / 64 rewrites, two pooled name allocations, and both caller names intact. Its former WILL_FAIL registration can therefore become a normal pass when both PRs are present.
AI-assisted (Codex). |
ecbbf3e to
19d5731
Compare
|
Thanks @SuperCraft3M for the independent integration check with Rebased
|
b504827 to
2dd69cd
Compare
|
Updated the branch for the conflict with main.
AI-assisted; commands listed were executed locally. |
|
Updated the branch for the new conflict with main (merge, no force push).
AI-assisted; commands listed were executed locally. |
36bb4ad to
17fcad7
Compare
Two threads entering the same hooked function could run through the step-over window untraced. The debugger now holds every other thread for the step, defers a hit that trapped before the hold, bounds each window with a deadline and always reports how many windows were unprotected.
…window A thread that was not held no longer raises when it steps at another hook: the open window stays with its owner and is reported as exposed. Only a held thread is deferred.
With the step window off, another thread can re-patch the hook byte before the stepping thread runs the original instruction, so the thread traps again at the same address and stack slot. The call was registered twice and its return wrote two lines (88 traces for 64 opens). Pending returns are now keyed by thread and slot, and the control counts lost opens as max(0, 64 - traced). The overlap probe uses four threads with a spin barrier.
…others A thread that has called ExitThread stays in the debugger's thread list until its exit event is read. OpenThread still works on it but SuspendThread and GetThreadContext fail with access denied, and the window counted that as an unprotected window although the thread runs no code. A hold that fails is now classified after the failure: GONE when GetExitCodeThread is not STILL_ACTIVE (or the handle is already signaled), FAILED when the thread is alive. The decision is a pure function in hook_window.py checked by startup_hook_window. Refs R0Y00#1281
…one; reuse the debug event's thread handle Thanks @RenzoWit35 for the Win11 26300 finding.
17fcad7 to
4593de9
Compare
|
Closing this PR for now to keep the Windows test queue short. Nothing is wrong with it and the branch stays as it is. We will reopen it once the queue is clear, re-run the Win2025 WARP checks at its head, and post the result here. AI-assisted; commands listed were executed locally. |
The hook window replaced the returns dict with ReturnBook; the hit-limit release still called returns.get(addr), which the class does not have.
The merge left a second file_log assignment that opened files.txt only when tracing, overriding the main definition that also opens it for X2W_LOG_AT. startup_debug_log then failed with a None log.
|
Win2025 receipt for head 88e0aa8 (origin/main merged in, no force push):
AI-assisted; commands listed were executed locally. |
|
Independent Stage-2 gate of head 08f0f4e: PASS (supersedes my receipt for 88e0aa8). Checked:
Verification (Win2025, proxmox only):
Not covered, as the PR says: the two-thread Update, head 08f0f4e ( AI-assisted; commands listed were executed locally. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
A hooked call may change its arguments for the call only (a mapped drive name). The book now keeps an optional restore per call and runs it once on the return, so the caller's state is back before anything else runs; a re-trap of the same call keeps the first restore.
|
Head moved to 08f0f4e: ReturnBook gets an optional per-call restore callback (run once when the call returns; a re-trap of the same call keeps the first restore), so #1251 can restore a rewritten name through the same return book. Covered in startup_hook_check. Win2025 (build 26100) on 08f0f4e: startup_launch|startup_hook_window|startup_hook_overlap|startup_debug dev 7/7 and release 7/7 passed (hook_overlap 64 of 64 with the window, control loses opens). AI-assisted; commands listed were executed locally. |
|
@MasterDomino these are tested and Ready. Could you merge them in this order when you have a moment?
Each PR has its Win2025 dev + release receipt in its comments. Thanks! |
Fixes #1281
What this unblocks: a startup run that traces every call of a hooked function even when two threads enter it at once (files.txt, the offline socket refusal and rewrites built on the hook no longer miss concurrent calls).
Source: Microsoft Win32 debugging API documentation: WaitForDebugEvent / ContinueDebugEvent (https://learn.microsoft.com/windows/win32/api/debugapi/nf-debugapi-waitfordebugevent), SuspendThread and GetThreadContext (https://learn.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-suspendthread); the single-step trap flag is the x86 EFLAGS TF bit.
Change
The startup debugger's function hooks are one patched byte per function. To run the original instruction it restores the byte, single-steps the thread that hit it and patches the byte again. A second thread entering the same function in that window ran untraced, so files.txt, the offline socket refusal and any rewrite built on the hook missed calls.
Chosen fix: hold every other thread for the step (SuspendThread plus a GetThreadContext to wait until it has stopped), step the owner alone, patch the byte again, then resume them. Why this and not the alternatives:
Details:
hook windows: entries=N windows=W unprotected=U deferred=D timeouts=T protection=on|offin the console, finished.txt and files.txt, also when all are 0.--suspend-others 0turns the holding off, to measure it or to see the loss.Bookkeeping is in tools/startup/hook_window.py (no Win32 calls) so it can be checked without Windows.
Verification
Linux, run here:
python3 -B tests/startup_hook_check.py: PASS. Five single mutations of hook_window.py (defer never, any thread closes the window, deadline not counted, failed hold not counted, owner held) each make it fail.py_compileof the three Python files,tests/docs_links_check.py,tests/bidi_controls_check.py,git diff --check: clean.Windows (Win2025, D3D12 WARP node, MSVC 14.44, Windows Server 2025 build 26100), PR head 88e0aa8 (origin/main merged in, merge commit, no force):
startup_hook_overlap: 64 of 64 opens traced with the window, three times,unprotected=0; the control with--suspend-others 0lost opens and reportedunprotectedabove 0.returns.get(addr)(the class has noget;ReturnBook.pending()added with a test), and a duplicatefile_logassignment overrode main'strace or log_at(startup_debug_log failed before the fix, passes after).--map-drivecase needs startup: map a console package drive letter to a real folder #1251, which is not in main.Evidence and follow-up
prpreset: startup_hook_window, startup_hook_overlap.returns, so it needs no change for this fix. This PR does not touch those lines; it applies on main without startup: map a console package drive letter to a real folder #1251.Checklist
AI-assisted; commands listed were executed locally.