Fix UI-thread hang when resuming the target during launch#1596
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a Visual Studio UI/SDM-thread hang during launch by decoupling AD7Engine.ContinueFromSynchronousEvent (ProgramCreate path) from blocking debugger I/O, while still preserving operation serialization behind the worker thread’s “running-op” slot.
Changes:
- Added
WorkerThread.PostAsyncOperationto dispatch anAsyncOperationwithout blocking the caller while still claiming the running-op slot. - Routed
AD7Engine.ContinueFromSynchronousEventlaunch-resume (ResumeFromLaunch) through the new non-blocking dispatch so it can returnS_OKimmediately. - Added an error-handler pathway for
PostAsyncOperationfaults and surfaced them via an engine callback.
Show a summary per file
| File | Description |
|---|---|
| src/MIDebugEngine/Engine.Impl/OperationThread.cs | Introduces PostAsyncOperation and error-handler plumbing for async operations. |
| src/MIDebugEngine/AD7.Impl/AD7Engine.cs | Stops blocking the UI thread on ResumeFromLaunch by posting it asynchronously and handling failures via callback. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Low
AD7Engine.ContinueFromSynchronousEvent (the AD7ProgramCreateEvent path) dispatched ResumeFromLaunch through the blocking WorkerThread.RunOperation, coupling the VS UI/SDM thread to debugger I/O. Over a slow or remote (SSH) transport, AD7Engine.ContinueFromSynchronousEvent + ResumeFromLaunch could stall for a long time or indefinitely, producing a Watson hang. - Add WorkerThread.PostAsyncOperation, a non-blocking dispatch that claims the running-op slot (so later AD7 operations still serialize behind it) but returns without waiting for completion. Faults from the operation are routed to an onError callback from both the synchronous and async completion paths. - ContinueFromSynchronousEvent now posts ResumeFromLaunch via PostAsyncOperation and returns S_OK immediately, so the UI thread is no longer blocked. Resume faults report through SendStartDebuggingError + Terminate via onError, and synchronous failures (OnLoadComplete or the dispatch itself) are still handled locally, since the SDM drops errors returned from this method. - [x] Built and tested locally - [x] Debugged through WSL Linux gdb and the async resume completed.
WardenGnaw
force-pushed
the
dev/waan/2987836
branch
from
July 14, 2026 22:49
4114c5b to
32946b9
Compare
Address PR review: document that the ErrorHandler for an async operation may be invoked on a non-worker (task completion) thread, and invoke it while the running-op slot is still held so it does not run concurrently with the next queued operation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0b5e2926-4bce-44b8-bfab-8b9b7f36a615
WardenGnaw
force-pushed
the
dev/waan/2987836
branch
from
July 14, 2026 22:59
32946b9 to
42e8354
Compare
WardenGnaw
marked this pull request as ready for review
July 15, 2026 00:00
gregg-miskelly
approved these changes
Jul 15, 2026
gregg-miskelly
left a comment
Member
There was a problem hiding this comment.
Looks good aside from the one suggestion
Member
gregg-miskelly
approved these changes
Jul 15, 2026
gregg-miskelly
left a comment
Member
There was a problem hiding this comment.
Aside from Close, LGTM
Member
Author
|
Had to also fix thie issue with Background actions are getting stuck waiting in the queue and may never running because thread went back to sleep. |
gregg-miskelly
approved these changes
Jul 16, 2026
Member
Author
|
@microsoft-github-policy-service rerun |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AD7Engine.ContinueFromSynchronousEvent (the AD7ProgramCreateEvent path) dispatched ResumeFromLaunch through the blocking WorkerThread.RunOperation, coupling the VS UI/SDM thread to debugger I/O. Over a slow or remote (SSH) transport, AD7Engine.ContinueFromSynchronousEvent + ResumeFromLaunch could stall for a long time or indefinitely, producing a Watson hang.
Add WorkerThread.PostAsyncOperation, a non-blocking dispatch that claims the running-op slot (so later AD7 operations still serialize behind it) but returns without waiting for completion. Faults from the operation are routed to an onError callback from both the synchronous and async completion paths.
ContinueFromSynchronousEvent now posts ResumeFromLaunch via PostAsyncOperation and returns S_OK immediately, so the UI thread is no longer blocked. Resume faults report through SendStartDebuggingError + Terminate via onError, and synchronous failures (OnLoadComplete or the dispatch itself) are still handled locally, since the SDM drops errors returned from this method.
Built and tested locally