Skip to content

vstest.console hangs indefinitely if testhost dies #706

Closed

Description

Description

vstest.console may hang indefinitely if the testhost process dies

Steps to reproduce

dotnet new xunit
Add this test:

using System;
using System.Threading;
using Xunit;

namespace testfail
{
    public class UnitTest1
    {
        [Fact]
        public void Passes()
        {
        }

        [Fact]
        public void OtherThreadFails()
        {
            Thread.Sleep(1000);
            Action fail = () => throw new InvalidOperationException();
            var thread = new Thread(new ThreadStart(fail));
            thread.Start();
            thread.Join();
        }
    }
}

Expected behavior

If test host dies, vstest.console should fail the test run.

Actual behavior

Error printed to console:

The active test run was aborted. Reason: Unable to communicate with test host process.

Then the vstest.console.dll process hangs forever.

image

The hung process:

"dotnet" exec "C:\Program Files\dotnet\sdk\1.0.3\vstest.console.dll" --framework:".NETCoreApp,Version=v1.1" --logger:console;verbosity=normal "C:\tmp\testfail\bin\Debug\netcoreapp1.1\testfail.dll"

When attaching to the hung process, the process has two threads that are deadlocked.

Main thread
>	System.Private.CoreLib.ni.dll!System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle waitableSafeHandle, long millisecondsTimeout, bool hasThreadAffinity, bool exitContext)	Unknown
 	System.Private.CoreLib.ni.dll!System.Threading.WaitHandle.WaitOne(int millisecondsTimeout, bool exitContext)	Unknown
 	Microsoft.VisualStudio.TestPlatform.Client.dll!Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.WaitForCompletion(int timeout)	Unknown
 	Microsoft.VisualStudio.TestPlatform.ObjectModel.dll!Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.RequestExtensions.WaitForCompletion(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.IRequest request)	Unknown
 	vstest.console.dll!Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers.TestRequestManager.RunTests(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.TestRunCriteria testRunCriteria, Microsoft.VisualStudio.TestPlatform.Common.Interfaces.ITestRunEventsRegistrar testRunEventsRegistrar)	Unknown

Worker thread
>	System.Private.CoreLib.ni.dll!System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle waitableSafeHandle, long millisecondsTimeout, bool hasThreadAffinity, bool exitContext)	Unknown
 	System.Private.CoreLib.ni.dll!System.Threading.WaitHandle.WaitOne(int millisecondsTimeout, bool exitContext)	Unknown
 	Microsoft.TestPlatform.CoreUtilities.dll!Microsoft.VisualStudio.TestPlatform.Utilities.JobQueue<System.Action>.BackgroundJobProcessor()	Unknown
 	Microsoft.TestPlatform.CoreUtilities.dll!Microsoft.VisualStudio.TestPlatform.Utilities.JobQueue<System.__Canon>..ctor.AnonymousMethod__12_0()	Unknown

Environment

dotnet.exe 1.0.3
Windows 10, x64
Microsoft.NET.Test.Sdk 15.0.0
xunit 2.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions