Bug 53780 - Process.Kill is throwing a SafeHandleClosed exception
Summary: Process.Kill is throwing a SafeHandleClosed exception
Status: RESOLVED FEATURE
Alias: None
Product: Runtime
Classification: Mono
Component: io-layer ()
Version: 4.8.0 (C9)
Hardware: PC Mac OS
: High blocker
Target Milestone: 15.2
Assignee: Ludovic Henry
URL:
Depends on:
Blocks:
 
Reported: 2017-03-22 12:41 UTC by Alan McGovern
Modified: 2017-03-29 19:53 UTC (History)
6 users (show)

Tags: 2017-02
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FEATURE

Description Alan McGovern 2017-03-22 12:41:52 UTC
Stacktrace: https://gist.github.com/alanmcgovern/20d75242fc94264c9d7c2178996f3f8e

Calling Process.Kill on a process which has exited shouldn't crash :(

we're basically doing: `var process = Process.Start ()` and then invoking `process.Kill` at some point after the process has aleady been killed/died.
Comment 1 Alan McGovern 2017-03-22 12:47:30 UTC
Alans-MacBook-Pro:md-addins alan$ mono --version
Mono JIT compiler version 4.8.0 (mono-4.8.0-branch/8f6d0f6 Thu Mar  9 12:07:34 EST 2017)
Comment 2 Alan McGovern 2017-03-27 10:17:34 UTC
This is another occurrence: https://gist.github.com/alanmcgovern/7a32d183c8805a925bfac53576924b37
Comment 3 Ludovic Henry 2017-03-27 16:04:03 UTC
The second crash (in comment #2) is expected bahaviour, as it's 100% referencesource code.

For the first crash, it looks like the Process has been closed before calling Kill, as the handle has been disposed, which only happens when calling Process.Close. Could you point to where the code is?
Comment 5 Alan McGovern 2017-03-27 16:12:33 UTC
Oh, i linked code for the second case, not the first.

If the second case is supposed to do that then we're going to have to patch our code to compensate. We can do that.
Comment 6 Alan McGovern 2017-03-27 16:21:49 UTC
If change the code to bypass the second issue we'll probably start triggering the first issue again. Let's start with that and see where we end up.
Comment 7 Ludovic Henry 2017-03-27 16:28:10 UTC
What seems weird with the code you linked is passing process to https://github.com/xamarin/md-addins/blob/master/Xamarin.Designer.iOS/tests/MonoTouch.Designer.Client.Tests/FixtureHelpers/TestHarnessAgentLauncher.cs#L53 as process is going to be disposed as part of RobustifiedStream.Dispose, and I am afraid that would race with https://github.com/xamarin/md-addins/blob/master/Xamarin.Designer.iOS/tests/MonoTouch.Designer.Client.Tests/FixtureHelpers/TestHarnessAgentLauncher.cs#L24