Skip to content

Terminate the TTD target on the engine thread - #1182

Merged
xusheng6 merged 2 commits into
devfrom
test_1129_ttd_quit_thread
Aug 17, 2026
Merged

xusheng6 merged 2 commits into
devfrom
test_1129_ttd_quit_thread

Conversation

@xusheng6

Copy link
Copy Markdown
Member

DbgEng clients are thread-affine, and ExitDispatch() is the only call documented as safe from another thread. Quit() was calling TerminateCurrentProcess() from the requesting thread while the engine thread sat in DispatchCallbacks(), which faults inside WinDbg 1.2606's new V8-based JSProvider.dll.

Quit() now only raises m_terminateRequested and wakes the engine loop, which performs the terminate itself.

Reproduced with a harness mirroring the adapter (callbacks, worker thread, engine loop): 5/5 crashes before, 0/10 after on 1.2606, and 0/3 on 1.2603. WinDbg 1.2402 and 1.2603 never crashed either way, so the pinned version was already a valid mitigation.

Untested path: if the trace is replaying rather than sitting at a break, Quit() falls back to SetInterrupt(); the harness always stopped at a break.

Fixes #1129

🤖 Generated with Claude Code

DbgEng clients are thread-affine, and ExitDispatch() is the only call
documented as safe from another thread. Quit() was calling
TerminateCurrentProcess() from the requesting thread while the engine
thread sat in DispatchCallbacks(), which faults inside WinDbg 1.2606's
new V8-based JSProvider.dll.

Quit() now only raises m_terminateRequested and wakes the engine loop,
which performs the terminate itself.

Reproduced with a harness mirroring the adapter: 5/5 crashes before,
0/10 after on 1.2606, and 0/3 on 1.2603. WinDbg 1.2402 and 1.2603 never
crashed either way.

Fixes #1129

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@xusheng6
xusheng6 requested a review from plafosse August 14, 2026 21:34

@fuzyll fuzyll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not going to mark this "request changes" because I'm not super confident about my claims or the effect they'll have. But, I'm also not sure we should accept this as-is, either.

Comment thread core/adapters/dbgengadapter.h
Comment thread core/adapters/dbgengadapter.cpp Outdated
Comment thread core/adapters/dbgengttdadapter.cpp
Review feedback on #1182.

m_terminateRequested was only ever cleared by EngineLoop() consuming it, but
the controller reuses one adapter object across launches, so a request the
engine loop never got to (the trace reaching its end first, say) stayed
latched and would kill the next session's target at its first control
operation. Clear it once per session, at the top of EngineLoop(): both the
launch and the attach path run it on the engine thread, and the worker queue
cannot deliver a Quit() before the launch operation completes, so no live
request can be lost there.

Also log a failed terminate. Quit() has already reported success to the
controller by then, so the engine loop is the only place the failure can be
surfaced.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@xusheng6
xusheng6 requested review from fuzyll and removed request for plafosse August 17, 2026 19:07

@fuzyll fuzyll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think there has to be something better we can do when the debug adapter is stuck, but at least if we're able to warn/error there, it's useful.

Also appears the other issue I raised is now addressed. If we're confident the ExecStatus() is fine, I have no remaining issues with this PR. Thanks!

@xusheng6
xusheng6 merged commit 14a179d into dev Aug 17, 2026
2 checks passed
@xusheng6
xusheng6 deleted the test_1129_ttd_quit_thread branch August 17, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DbgEng TTD adapter crashes on stopping debugging when using latest WinDbg

2 participants