-
Notifications
You must be signed in to change notification settings - Fork 266
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
Test Host process crashes on Linux when a thread in a test method throws, but not on Windows #887
Comments
Hi @odalet, Thanks for reporting this issue and sorry it took so much time to review it! Your reproducer is not totally right and currently it's working mainly because the lambda is not yet triggered by the time you reach the assertion on Windows while it is on Linux.. By updating the repro as such: [TestMethod]
public void Repro()
{
var ok = false;
var threadLambdaWasCalled = false;
try
{
var thread = new Thread(() =>
{
ok = true;
threadLambdaWasCalled = true;
throw new Exception("TEST");
});
thread.Start();
}
catch
{
ok = false;
Assert.Fail("Reached catch");
}
while (!threadLambdaWasCalled)
{
Thread.Sleep(100);
}
Thread.Sleep(100);
Assert.IsTrue(ok);
} You will have the same behavior in Windows/Linux. On Windows, I still can see some difference between netfx and netcore. We need to investigate furthermore to see what's the difference and how we can improve this behavior. |
Thanks for your reply. Indeed, with your repro I end up with a similar crash in Linux and Windows (at least this is consistent!) <PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" /> And as expected, same behavior. |
Thanks for the confirmation. |
Description
Some unit tests have the test host crash when run on a Linux machine, but not on Windows
Steps to reproduce
Expected behavior
Actual behavior
Remarks
I reproduced the issue with this code:
It's obviously wrong but models what I suppose happens in my real unit tests. What has the test host crash is, I think, the fact that the thread keeps running after the test method ends, then throws, and this exception is not caught by the Linux version of the test engine.
Environment
The text was updated successfully, but these errors were encountered: