Stop the process before terminating it - #39
Closed
nevse wants to merge 1 commit into
Closed
Conversation
ICorDebugProcess::Terminate needs the process synchronized. On a running debuggee it fails with CORDBG_E_PROCESS_NOT_SYNCHRONIZED, the exception is caught and logged, and the request answers success while the process keeps running. Stopping first is what Disconnect already does for the non-terminating path. Terminate disposes whether or not the terminate worked, so a client that sends terminate and then disconnect disposes twice and the second one throws ChannelClosedException out of Dispose, surfaced as "Failed to disconnect". TryComplete makes the second dispose harmless.
Owner
|
Thanks, implemented in 039f36e |
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.
Fixes #38.
ICorDebugProcess::Terminateneeds the process synchronized. On a running debuggee it fails withCORDBG_E_PROCESS_NOT_SYNCHRONIZED (0x80131302), the exception is caught and logged, and the request answers success while the process keeps running. Stopping first is whatDisconnectalready does on its other branch, so this reuses the sameTryIsRunning/TryStoppair.The second change is
TryCompleteinstead ofCompleteon the runtime event channel.Terminate()disposes whether or not the terminate worked, soterminatefollowed bydisconnectdisposes twice and the second one throwsChannelClosedExceptionout ofDispose, surfaced asFailed to disconnect.Measured over
SharpDbgInMemory+DebugProtocolHost, launching a console app and killing it four ways:terminatewhile stopped at a breakpointdisconnect(terminateDebuggee: true)while stoppedterminatewhile runningdisconnect(terminateDebuggee: true)while runningAnd
disconnectafter aterminateno longer fails.SharpDbg.Cli.Tests32 of 32, three times, and 32 of 32 on 534170d as a control. Two runs failed on the way there, one on each side. The one I captured is on your main rather than on this branch, and it is the environment:ServerNotAvailableExceptionfor a staledotnet-diagnostic-*-socketin$TMPDIR. Every debuggee killed rather than detached leaves one behind, and after a while the next attach cannot connect - I had 129 dead ones to clear before the suite was reliable again.No test: it needs a launched debuggee, and the only launch scaffolding is in #34. Once that lands this is a few lines on top of
LaunchTests- happy to add it there, or here if you would rather have the test first.