Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vstest.console hangs indefinitely if testhost dies #706

Closed
natemcmaster opened this issue Apr 11, 2017 · 3 comments
Closed

vstest.console hangs indefinitely if testhost dies #706

natemcmaster opened this issue Apr 11, 2017 · 3 comments
Assignees
Labels
Milestone

Comments

@natemcmaster
Copy link
Contributor

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

@smadala
Copy link
Contributor

smadala commented Apr 13, 2017

@natemcmaster Can you please provide link for dotnet sdk 1.0.3 download?
Please share C:\Program Files\dotnet\sdk\1.0.3\vstest.console.dll Properties->Digital Signature-> timestamp?

@natemcmaster
Copy link
Contributor Author

vstest.console.dll = ‎Thursday, ‎April ‎6, ‎2017 8:35:18 PM

Not sure where to get the 1.0.3 SDK publicly. It is installed via the internal VS channel. @livarcocc might know.

@codito codito added this to the 15.3 milestone Apr 16, 2017
@Faizan2304 Faizan2304 assigned Faizan2304 and unassigned smadala Apr 25, 2017
Faizan2304 added a commit to Faizan2304/vstest that referenced this issue May 10, 2017
1) microsoft#706
2) microsoft#618

Fix:
Don’t serialize the type if that have self-referencing loop
Faizan2304 added a commit that referenced this issue May 11, 2017
* Dont pick package from fallbackPackageFolders as we want all the packages in vstest\package folder

* Issue:
1) #706
2) #618

Fix:
Don’t serialize the type if that have self-referencing loop

* Address PR comment.

* Log the exception in EqtTrace thrown from OnDiscoveryAbort and OnTestRunAbort
@Faizan2304
Copy link
Contributor

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants