Repository navigation
fix(debugger): cancel timed-out commands on dump sessions - #124
robster7674 wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
svnscha
left a comment
There was a problem hiding this comment.
Thanks for the fix. I retargeted this to develop, which is the working branch; main tracks the last release.
One regression needs correcting before merging: in src/mcp_windbg/debug_session.py:374, the new dump-only abandoned-marker branch replaces buffer without updating self._reader_buffer. After a late marker is discarded, subsequent output is appended to the new list, but _snapshot_partial_output() still reads the old list. A later timeout can therefore return empty or stale partial output instead of the current command's diagnostics.
Please add self._reader_buffer = buffer immediately after buffer = [], matching the expected-marker branch above, and cover partial-output capture after an abandoned marker. I reproduced this with the existing fake debugger by delivering a stale marker, then making !clrstack print output while swallowing its completion marker: partial_output is [] instead of ["OUT:!clrstack"]. The same test passes on develop and with that one-line correction applied in memory.
Validation otherwise looks good: all four new regressions fail against develop and pass with this PR; the full Windows suite passes with 160 passed, 2 skipped and 93% coverage. The skips are the two live-kernel scenarios because no kernel target is configured. I also checked follow-up commands after timeouts on both committed dump fixtures with real CDB and KD; the PR keeps abandoned output out of those replies.
…arker The dump-only abandoned-marker branch replaced the reader's buffer without updating self._reader_buffer, so _snapshot_partial_output() kept reading the old list. A command that timed out after a late marker was discarded reported empty or stale partial output instead of its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the careful review and the repro. Fixed in 14c281d:
Edit: replaced my earlier Linux-only numbers with a Windows run. I ran the steps of the
Correction to what I wrote here before: I had said two tests failed on Linux because of running off-Windows, without having checked. Both pass on Windows in all five runs above, and the Linux causes are:
CI on this PR is still waiting for workflow approval. |
|
Landed as #138. Thank you - the diagnosis was right, the mechanism works, and you were right to push on it. I verified the premise rather than taking it on trust, because "CTRL+BREAK cancels a command the engine is running on a static dump" is the kind of claim a fake cannot settle. On a real And the wedge you describe, before and after, with a 3 second timeout:
Two changes from your version. The stray-break absorb is not included. Its premise is that a break reaching an idle debugger stays pending and aborts the next real command. Measured, such a break is dropped. The only command at risk is one starting within about 10ms of the signal (at a 0ms gap 7 of 15 were truncated; at 10ms or more, 0 of 15), and with the absorb in place 3 of 12 were still truncated, so it did not close the window it aimed at. In practice the next command arrives after a model round trip. That is about 25 source and 16 test lines left out, and it is the only part of your patch I would ask you to drop if you carry this downstream. Lost sync is handled per session kind. Rather than your "may need a manual break-in" hint, which a dump user cannot act on because Also corrected: the comments referenced issues #449 and #468, which do not exist in this repository. One thing I added, because your own note said the hermetic tests mostly encode the fake: Still outstanding and noted in my own notes: |
What this changes
A command that outruns its timeout is now cancelled with CTRL+BREAK on dump sessions too, not only live targets. Related hardening, all in
debug_session.py:.echo <marker>absorbs a break that may still be pending (the slow command can finish between the timeout and the signal), so it cannot abort the next real command early with truncated output that reads as success.Why
With
open_kd_dump(1.4.0) people will open large kernel dumps.!process 0 7over one runs for minutes. Today, on a dump session nothing breaks in, so kd keeps running it and every later command (the retry,!irql, even.echo) queues behind it and times out too: the session is wedged until closed. We hit this on real complete dumps; verified on kd that!process 0 7stops within about a second after CTRL+BREAK and the next command runs normally.How it was verified
Four new hermetic tests in
test_debug_session.py(cancel-and-continue on a dump, the no-op ahead of the next command, late output of an abandoned command, and the Unicode-log case), plus the existingtest_debug_session.py/test_unicode_log.pysuites. Run on Linux with a stubwinreg; the onetest_kd_session.pyfailure there is the existing hard-codedC:\fake\dumpsassertion, which is Windows-only. The live kd check above was run by hand on a Windows worker.Happy to split this (cancel-on-dump vs. the stray-break no-op vs. late-output handling) or adjust style if you would rather review it in pieces. We carry this as a patch in our vendored copy and would like to converge on upstream.