Shift F5 , While debugging a core Unit test project causes dotnet.exe to crash
Repro steps
- Create a core class Library
- Add below in your project.json file
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"System.Runtime.Serialization.Primitives": "4.1.1-rc2-24027",
"xunit": "2.1.0",
"dotnet-test-xunit": "1.0.0-rc2-build10025"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"netstandardapp1.5",
"dnxcore50",
"portable-net45+win8"
]
}
},
"testRunner": "xunit"
}
- Add below to your class1.cs
using Xunit;
namespace UnitTest1
{
public class Class1
{
[Fact]
public void UnitTest1()
{
Assert.True(true);
}
[Fact]
public void UnitTest2()
{
Assert.False(true);
}
}
}
- Run the Unit test and make sure every thing works .
- Put a breakpoint in your first test , then do a debug test on that.
- When the breakpoint hits , Press SHIFT F5
I get this

I can give access to my repro machine, if anyone want to take a look.
@gkhanna79
I think @brthor or @piotrpMSFT are the right folks to help look into this.
@BillHiebert @vijayrkn Can you guys tell @jinujoseph how to get more detailed logs from the machine. So that we can see what dotnet is trying to do.
you can set DOTNET_TEST_TRACE=1 and this should show all the messaging between adapter and dotnet.exe process.
@vijayrkn I am trying to determine if this is a crash of the adapter or of the muxer that is running the test runner.
If it is the adapter, then I need to go look into it. If it is the muxer, then @schellap needs to take a look.
Logs says .. ------ Run test started ------ Running tests in 'C:\ProjectK\UnitTest1\src\UnitTest1\project.json' ["C:\Program Files\dotnet\dotnet.exe" test "C:\ProjectK\UnitTest1\src\UnitTest1\project.json" --output "C:\ProjectK\UnitTest1\src\UnitTest1\bin\Debug\netcoreapp1.0" --port 49858 --parentProcessId 3108 --no-build] The active Test Run was aborted because the execution process exited unexpectedly. To investigate further, enable local crash dumps either at the machine level or for process vstest.executionengine.x86.exe. Go to more details: http://go.microsoft.com/fwlink/?linkid=232477 ========== Run test finished: 0 run (0:00:30.7709168) ==========
adapter crash won't say "dotnet has stopped working". Can we look at the eventvwr.exe to see if it has more info on the crash?
so, this was the muxer. What are you guys doing when you say stop debugging? @schellap Can you take a look at this?
i see this in the eventviewer
Faulting application name: dotnet.exe, version: 1.0.1.4500, time stamp: 0x576218d2 Faulting module name: KERNELBASE.dll, version: 10.0.10240.16766, time stamp: 0x56e8d499 Exception code: 0xe0434352 Fault offset: 0x000000000002a1c8 Faulting process id: 0x15b0 Faulting application start time: 0x01d1cda144191a95 Faulting application path: C:\Program Files\dotnet\dotnet.exe Faulting module path: C:\Windows\system32\KERNELBASE.dll Report Id: ac35b1f3-9679-4cc2-80bc-99b8dbb8c829 Faulting package full name: Faulting package-relative application ID:
we call this method from Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IFrameworkHandle to start the process with Debugger attached.
int LaunchProcessWithDebuggerAttached(string filePath, string workingDirectory, string arguments, IDictionary<string, string> environmentVariables);
I would assume stopping the debugger stops/aborts this process.
So, here is my take then: I believe that the process is not being aborted, but the adapter is being aborted. Now, the runner is trying to send test results on a channel that is now closed and it crashes. Can you guys double check that you are killing the runner process when you stop debugging?
couldn't it be -
- VS test adapter launches the runner with debugger attached.
- dotnet.exe connects to the runner to get the results.
- When debugger is stopped, runner process is aborted.
- Because the dotnet.exe was connected to the runner to get the results, when runner stops dotnet.exe crashes.
why do you think the VStest adapter is aborted first?
Here is the stack:
https://github.com/dotnet/cli/blob/04f40f906dce2678d80fb9787e68de76ee6bf57e/src/dotnet/commands/dotnet-test/ReportingChannels/ReportingChannel.cs#L114
Contains dotnet_7ffd76160000!Microsoft.DotNet.Tools.Test.ReportingChannel.ReadMessages
CLR exception type: System.IO.IOException
"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."
KERNELBASE!RaiseException+0x68:
00007ffd`89dda1c8 488b8c24c0000000 mov rcx,qword ptr [rsp+0C0h] ss:000000dc`4c9d88e0=000006486a55d2b5
0:008> k
# Child-SP RetAddr Call Site
00 000000dc`4c9d8820 00007ffd`69d730bd KERNELBASE!RaiseException+0x68 [d:\th\minkernel\kernelbase\xcpt.c @ 858]
01 000000dc`4c9d8900 00007ffd`69e1dfae coreclr!RaiseTheExceptionInternalOnly+0x369 [d:\a\_work\38\s\src\vm\excep.cpp @ 3113]
02 000000dc`4c9d8a20 00007ffd`674e61ef coreclr!IL_Rethrow+0xae [d:\a\_work\38\s\src\vm\jithelpers.cpp @ 5427]
03 000000dc`4c9d8b70 00007ffd`69e00eb9 System_Private_CoreLib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)+0x10f [D:\A\_work\38\s\src\mscorlib\src\System\Threading\ExecutionContext.cs @ 95]
04 000000dc`4c9d8bc0 00007ffd`69dfe5cc coreclr!ExceptionTracker::CallHandler+0x131 [d:\a\_work\38\s\src\vm\exceptionhandling.cpp @ 3367]
05 000000dc`4c9d8c20 00007ffd`69dfec16 coreclr!ExceptionTracker::CallCatchHandler+0xf0 [d:\a\_work\38\s\src\vm\exceptionhandling.cpp @ 582]
06 000000dc`4c9d8ce0 00007ffd`8c9b66ed coreclr!ProcessCLRException+0x4e6 [d:\a\_work\38\s\src\vm\exceptionhandling.cpp @ 1105]
07 000000dc`4c9d8e10 00007ffd`8c93458c ntdll!RtlpExecuteHandlerForUnwind+0xd [d:\th\minkernel\ntos\rtl\amd64\xcptmisc.asm @ 252]
08 000000dc`4c9d8e40 00007ffd`69e01d28 ntdll!RtlUnwindEx+0x38c [d:\th\minkernel\ntos\rtl\amd64\exdsptch.c @ 1023]
09 000000dc`4c9d9520 00007ffd`69dfebbd coreclr!ClrUnwindEx+0x40 [d:\a\_work\38\s\src\vm\exceptionhandling.cpp @ 5169]
0a 000000dc`4c9d9a40 00007ffd`8c9b666d coreclr!ProcessCLRException+0x48d [d:\a\_work\38\s\src\vm\exceptionhandling.cpp @ 1060]
0b 000000dc`4c9d9b70 00007ffd`8c933c00 ntdll!RtlpExecuteHandlerForException+0xd [d:\th\minkernel\ntos\rtl\amd64\xcptmisc.asm @ 131]
0c 000000dc`4c9d9ba0 00007ffd`8c9321c4 ntdll!RtlDispatchException+0x370 [d:\th\minkernel\ntos\rtl\amd64\exdsptch.c @ 550]
0d 000000dc`4c9da2a0 00007ffd`89dda1c8 ntdll!RtlRaiseException+0x324 [d:\th\minkernel\ntos\rtl\amd64\raise.c @ 160]
0e 000000dc`4c9daa80 00007ffd`69d730bd KERNELBASE!RaiseException+0x68 [d:\th\minkernel\kernelbase\xcpt.c @ 858]
0f 000000dc`4c9dab60 00007ffd`69e1dfae coreclr!RaiseTheExceptionInternalOnly+0x369 [d:\a\_work\38\s\src\vm\excep.cpp @ 3113]
10 000000dc`4c9dac80 00007ffd`761e0dca coreclr!IL_Rethrow+0xae [d:\a\_work\38\s\src\vm\jithelpers.cpp @ 5427]
11 000000dc`4c9dadd0 00007ffd`69e00eb9 dotnet_7ffd76160000!Microsoft.DotNet.Tools.Test.ReportingChannel.ReadMessages()+0xda
12 000000dc`4c9dae30 00007ffd`69dfe5cc coreclr!ExceptionTracker::CallHandler+0x131 [d:\a\_work\38\s\src\vm\exceptionhandling.cpp @ 3367]
13 000000dc`4c9dae90 00007ffd`69dfec16 coreclr!ExceptionTracker::CallCatchHandler+0xf0 [d:\a\_work\38\s\src\vm\exceptionhandling.cpp @ 582]
14 000000dc`4c9daf50 00007ffd`8c9b66ed coreclr!ProcessCLRException+0x4e6 [d:\a\_work\38\s\src\vm\exceptionhandling.cpp @ 1105]
15 000000dc`4c9db080 00007ffd`8c93458c ntdll!RtlpExecuteHandlerForUnwind+0xd [d:\th\minkernel\ntos\rtl\amd64\xcptmisc.asm @ 252]
16 000000dc`4c9db0b0 00007ffd`69e01d28 ntdll!RtlUnwindEx+0x38c [d:\th\minkernel\ntos\rtl\amd64\exdsptch.c @ 1023]
17 000000dc`4c9db790 00007ffd`69dfebbd coreclr!ClrUnwindEx+0x40 [d:\a\_work\38\s\src\vm\exceptionhandling.cpp @ 5169]
18 000000dc`4c9dbcb0 00007ffd`8c9b666d coreclr!ProcessCLRException+0x48d [d:\a\_work\38\s\src\vm\exceptionhandling.cpp @ 1060]
19 000000dc`4c9dbde0 00007ffd`8c933c00 ntdll!RtlpExecuteHandlerForException+0xd [d:\th\minkernel\ntos\rtl\amd64\xcptmisc.asm @ 131]
1a 000000dc`4c9dbe10 00007ffd`8c9321c4 ntdll!RtlDispatchException+0x370 [d:\th\minkernel\ntos\rtl\amd64\exdsptch.c @ 550]
1b 000000dc`4c9dc510 00007ffd`89dda1c8 ntdll!RtlRaiseException+0x324 [d:\th\minkernel\ntos\rtl\amd64\raise.c @ 160]
1c 000000dc`4c9dccf0 00007ffd`69d730bd KERNELBASE!RaiseException+0x68 [d:\th\minkernel\kernelbase\xcpt.c @ 858]
1d 000000dc`4c9dcdd0 00007ffd`69e1def0 coreclr!RaiseTheExceptionInternalOnly+0x369 [d:\a\_work\38\s\src\vm\excep.cpp @ 3113]
1e 000000dc`4c9dcef0 00007ffd`6d1f03e2 coreclr!IL_Throw+0x180 [d:\a\_work\38\s\src\vm\jithelpers.cpp @ 5396]
1f 000000dc`4c9dd0a0 00007ffd`69e00eb9 System_Net_Sockets!System.Net.Sockets.NetworkStream.Read(Byte[], Int32, Int32)+0x252 [D:\A\_work\21\s\src\System.Net.Sockets\src\System\Net\Sockets\NetworkStream.cs @ 398]
20 000000dc`4c9dd100 00007ffd`69dfe5cc coreclr!ExceptionTracker::CallHandler+0x131 [d:\a\_work\38\s\src\vm\exceptionhandling.cpp @ 3367]
21 000000dc`4c9dd160 00007ffd`69dfec16 coreclr!ExceptionTracker::CallCatchHandler+0xf0 [d:\a\_work\38\s\src\vm\exceptionhandling.cpp @ 582]
22 000000dc`4c9dd220 00007ffd`8c9b66ed coreclr!ProcessCLRException+0x4e6 [d:\a\_work\38\s\src\vm\exceptionhandling.cpp @ 1105]
23 000000dc`4c9dd350 00007ffd`8c93458c ntdll!RtlpExecuteHandlerForUnwind+0xd [d:\th\minkernel\ntos\rtl\amd64\xcptmisc.asm @ 252]
24 000000dc`4c9dd380 00007ffd`69e01d28 ntdll!RtlUnwindEx+0x38c [d:\th\minkernel\ntos\rtl\amd64\exdsptch.c @ 1023]
25 000000dc`4c9dda60 00007ffd`69dfebbd coreclr!ClrUnwindEx+0x40 [d:\a\_work\38\s\src\vm\exceptionhandling.cpp @ 5169]
26 000000dc`4c9ddf80 00007ffd`8c9b666d coreclr!ProcessCLRException+0x48d [d:\a\_work\38\s\src\vm\exceptionhandling.cpp @ 1060]
27 000000dc`4c9de0b0 00007ffd`8c933c00 ntdll!RtlpExecuteHandlerForException+0xd [d:\th\minkernel\ntos\rtl\amd64\xcptmisc.asm @ 131]
28 000000dc`4c9de0e0 00007ffd`8c9321c4 ntdll!RtlDispatchException+0x370 [d:\th\minkernel\ntos\rtl\amd64\exdsptch.c @ 550]
29 000000dc`4c9de7e0 00007ffd`89dda1c8 ntdll!RtlRaiseException+0x324 [d:\th\minkernel\ntos\rtl\amd64\raise.c @ 160]
2a 000000dc`4c9defc0 00007ffd`69d730bd KERNELBASE!RaiseException+0x68 [d:\th\minkernel\kernelbase\xcpt.c @ 858]
2b 000000dc`4c9df0a0 00007ffd`69e1def0 coreclr!RaiseTheExceptionInternalOnly+0x369 [d:\a\_work\38\s\src\vm\excep.cpp @ 3113]
2c 000000dc`4c9df1c0 00007ffd`6d1f5130 coreclr!IL_Throw+0x180 [d:\a\_work\38\s\src\vm\jithelpers.cpp @ 5396]
2d 000000dc`4c9df370 00007ffd`6d1f0232 System_Net_Sockets!System.Net.Sockets.Socket.Receive(Byte[], Int32, Int32, System.Net.Sockets.SocketFlags)+0x50 [D:\A\_work\21\s\src\System.Net.Sockets\src\System\Net\Sockets\Socket.cs @ 1462]
2e 000000dc`4c9df3c0 00007ffd`6754e576 System_Net_Sockets!System.Net.Sockets.NetworkStream.Read(Byte[], Int32, Int32)+0xa2 [D:\A\_work\21\s\src\System.Net.Sockets\src\System\Net\Sockets\NetworkStream.cs @ 431]
2f 000000dc`4c9df420 00007ffd`6753ff13 System_Private_CoreLib_ni!System.IO.Stream.ReadByte()+0x36 [D:\A\_work\38\s\src\mscorlib\src\System\IO\Stream.cs @ 703]
30 000000dc`4c9df460 00007ffd`67540fa4 System_Private_CoreLib_ni!System.IO.BinaryReader.ReadByte()+0x23 [D:\A\_work\38\s\src\mscorlib\src\System\IO\BinaryReader.cs @ 141]
31 000000dc`4c9df4a0 00007ffd`67540615 System_Private_CoreLib_ni!System.IO.BinaryReader.Read7BitEncodedInt()+0x24 [D:\A\_work\38\s\src\mscorlib\src\System\IO\BinaryReader.cs @ 581]
32 000000dc`4c9df4e0 00007ffd`761e0d14 System_Private_CoreLib_ni!System.IO.BinaryReader.ReadString()+0x25 [D:\A\_work\38\s\src\mscorlib\src\System\IO\BinaryReader.cs @ 248]
33 000000dc`4c9df550 00007ffd`674e614e dotnet_7ffd76160000!Microsoft.DotNet.Tools.Test.ReportingChannel.ReadMessages()+0x24
34 000000dc`4c9df5b0 00007ffd`6a057463 System_Private_CoreLib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)+0x6e [D:\A\_work\38\s\src\mscorlib\src\System\Threading\ExecutionContext.cs @ 104]
35 000000dc`4c9df620 00007ffd`69db53e3 coreclr!CallDescrWorkerInternal+0x83 [D:\A\_work\38\s\src\vm\amd64\CallDescrWorkerAMD64.asm @ 101]
36 000000dc`4c9df660 00007ffd`69e402fd coreclr!MethodDescCallSite::CallTargetWorker+0x21b [d:\a\_work\38\s\src\vm\callhelpers.cpp @ 653]
37 (Inline Function) --------`-------- coreclr!MethodDescCallSite::Call+0x9 [d:\a\_work\38\s\src\vm\callhelpers.h @ 420]
38 000000dc`4c9df770 00007ffd`69d82460 coreclr!ThreadNative::KickOffThread_Worker+0x13d [d:\a\_work\38\s\src\vm\comsynchronizable.cpp @ 298]
39 000000dc`4c9df8e0 00007ffd`69d824f5 coreclr!ManagedThreadBase_DispatchInner+0x70 [d:\a\_work\38\s\src\vm\threads.cpp @ 10113]
3a 000000dc`4c9df920 00007ffd`69d82844 coreclr!ManagedThreadBase_DispatchMiddle+0x89 [d:\a\_work\38\s\src\vm\threads.cpp @ 10162]
3b 000000dc`4c9dfa80 00007ffd`69e4062e coreclr!ManagedThreadBase_DispatchOuter+0xb4 [d:\a\_work\38\s\src\vm\threads.cpp @ 10417]
3c (Inline Function) --------`-------- coreclr!ManagedThreadBase_FullTransitionWithAD+0x58 [d:\a\_work\38\s\src\vm\threads.cpp @ 10480]
3d (Inline Function) --------`-------- coreclr!ManagedThreadBase::KickOff+0x58 [d:\a\_work\38\s\src\vm\threads.cpp @ 10515]
3e 000000dc`4c9dfb30 00007ffd`69d7d4db coreclr!ThreadNative::KickOffThread+0x17e [d:\a\_work\38\s\src\vm\comsynchronizable.cpp @ 418]
3f 000000dc`4c9dfc20 00007ffd`8c4f2d92 coreclr!Thread::intermediateThreadProc+0x8b [d:\a\_work\38\s\src\vm\threads.cpp @ 2869]
40 000000dc`4c9dfee0 00007ffd`8c929f64 KERNEL32!BaseThreadInitThunk+0x22 [d:\th\base\win32\client\thread.c @ 64]
41 000000dc`4c9dff10 00000000`00000000 ntdll!RtlUserThreadStart+0x34 [d:\th\minkernel\ntdll\rtlstrt.c @ 994]
Dump here: \WNVM22143\TheDump
@vijayrkn You are right. It was one or the other. But from @schellap's stack above, it is clearly dotnet-test. I will fix it.
Actually, I will close this one and move it to the CLI (https://github.com/dotnet/cli/issues/3800).