-
Notifications
You must be signed in to change notification settings - Fork 320
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
The active test run was aborted. Reason: Test host process crashed #2261
Comments
@xuzhg I am not able to reproduce the issue. I followed the steps you have shared. |
We are getting this issue from time to time on our build server, too. It's not consistent and sometimes it works just fine. We didn't see before when we were running core 2.2, but now see when we are running 3.1 |
We were seeing similar issues in VS, there was a problem with cancellation of run that produced a cancellation error and was not caught in the correct place. It resulted in the same error, but probably not the same stack. That error is kind of a catch all for all errors when the other process disconnects in the middle of an operation so it is hard to tell. I would suggest upgrading to 16.5.0 to see if that was fixes. |
We are using vstest indirectly (via Microsoft.NET.Test.Sdk), and I have upgraded it to 16.5.0, and yet the error persists.
Are there any other recommendations? |
Our builds have started failing with this error. Is there a way to get some decent logs out? We are using azure hosted pipelines. We have been getting this error for months but it's been very intermittent, so hasn't bothered us. But over the past 2 days it has spiked hugely. |
I'm also seeing persistent test host crashes in a project that I contribute to. Links: |
In follow up to this I've created #2501 |
We had the exact same issue with our build. It turned out to be misconfigured settings for code coverage. In our CodeCoverage.runsettings-file we were not properly excluding test projects from coverage. |
We have (possibly) the same intermittent issue here. rough important list of packages in our UT test project:
Our default gitlab runner job is on a kubernetes runner, and defaults to docker image: Adding |
I have got here due to use of wrong function. |
Anyone has any update for this issue or any idea how to solve it? |
I am seeing the same error message both with vstest.console.exe on Visual Studio 2019 16.8.4 and with dotnet test.
With dotnet test I get this error in the Application event log: Faulting application name: testhost.net472.x86.exe, version: 15.0.0.0, time stamp: 0xd89b8ef9 With vstest.console.exe this error is logged: Faulting application name: testhost.net472.exe, version: 15.0.0.0, time stamp: 0x89f6cab7 A TestResults directory was created next to the test assembly, but it is completely empty. Any idea how I can find the cause of the error? |
@dbtfsbre you can install 5.0.101 dotnet SDK, and also install ProcDump so it is available in your PATH (if you open command line and type procdump, you should see output of the procdump tool). Then you do just:
And it should create a dump for you, open that in VS and you should see where that exception is coming from. Most likely it is your code calling some method recursively and forgetting to terminate. |
@nohwnd Thanks. Something went wrong when copying files to the test machine for an investigation. The test is running fine in Visual Studio using Test Explorer and during our regular Release test runs. After compiling the test again directly on the test machine, I was able to run it with dotnet test as well as vstest.console.exe. |
FWIW: the solution we found was actually due to OOM kills from kubernetes gitlab-runner setup. The nodes were stretching their RAM too tightly, and eventually digging showed events where k8s was killing the dotnet process. Looked like this:
This might not be the problem or solution for everyone, but wanted to share back as it is definitely something to consider! |
I'm having a similar problem. My actual test code, however, was a recursive function that would not exit the loop due to my test data. It also results in an infinite cycle. I adjusted my data to get out of the recursion function, and it worked. |
@jesperoastrom We have the same issue and it seems it is occurring since we re-activated code coverage. Can you please explain a little further, how you exactly solved your problem? |
@rkieslinger If i remember correctly, we were running the test command and collecting coverage using the arguments: |
Hi, have you fixed this issue? We have a similar problem with dotnet and gitlab + k8s. |
@demonccc - see #2261 (comment) |
Thanks for the response. Could you tell me what configuration have you changed in order to avoid de OOM killer? The k8s executor of Gitlab doesn't have this option, and you can't modify the OOM adj of kubernetes. Thanks in advance. |
It happens to me too when converting a project to use .net 5. We use NUnit and I made sure I use all the latest versions of the libraries. Out of more than 700 tests in one of the suites, 7 throw an exception such as this which crashes the test host process. Before changing to .net 5 (from .net framework 4.6.1, which means many changes were required but in those specific tests the flow seems untouched) everything worked. I debugged the old version and the new version simultaneously and I see the same exception getting thrown, but in the .net framework it's getting handled correctly and the test passes while in .net 5 the exception isn't handled by the test host process and it crashes. The test itself is quite short but hides complexities regarding threads, which might shed some light on where the problem is. Since the old code made use of |
Okay, I now have a reproduction for the problem, and it's thread related. This is the error I get:
and this is the code:
|
It seems, that this is the default behavior of the .net runtime (except 1.0 and 1.1; see There's not much vstest can do about it, i guess. For very special scenarios you can use the mentioned flag in your app.config. This will prevent the app from terminating when an unhandled exception happens in a thread. example app.config
|
@juwens Then how do you explain it works on .net 4.6? It's a different runtime... There's a specific problem introduced in .net core and above. |
just tried it with .net 4.5 target framework and it terminates the app too. Might be because clr tries to run code on the latest installed framework. which is 4.8 in my case. my code:
|
@juwens Yes, of course it breaks a PROGRAM, but we're discussing a UNIT TEST |
are you aware, that a running test is just .net program (test host) which invokes your unit-test methods? 🤔 |
Yes, of course I'm aware of that. Are you aware that this test host is
dynamically loading the tests from a DLL file? If it worked before then
there's no reason it'll break now, which means this test host isn't doing
it's job well. And I didn't try that since it's irrelevant for .net core
and up, which doesn't even read app.config files anymore. Besides, setting
the tests to run as STA isn't a good option since the code itself is
multithreaded and we want to test in parallel as much as possible.
…On Tue, Jan 18, 2022, 19:09 Jens ***@***.***> wrote:
@juwens <https://github.com/juwens> Yes, of course it breaks a PROGRAM,
but we're discussing a UNIT TEST
are you aware, that a running test is just .net program (test host) which
invokes your unit-test methods? 🤔
Of course it behaves the identical to a programm.
There is no magic in the test host.
Have you tried setting legacyUnhandledExceptionPolicy ?
—
Reply to this email directly, view it on GitHub
<#2261 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABCNNYAWGXDILPNP5N6VHTUWWNDRANCNFSM4JU4X5FQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I had this issue. Here is how I resolved it:
|
I recommend closing this issue. |
@brah-mcdude - if the application/test code itself caused the crash, this should be much more obvious/different from the other scenarios presented "The active test run was aborted. Reason: Test host process crashed" <-- too generic. |
@mcallaghan-geotab - Here is the message I was getting: "The active test run was aborted. Reason: Test host process crashed". My code caused it. I traced the call stack. Show me your code. I will show you the cause of this issue. |
I just got a similar problem with my application in .NET 6
Edit:
|
@cn-ml - you have a "Stack overflow". Show us your call-stack. |
I've been getting this same issue, but it seemingly occurs only when running a whole test project at once; if I try to test each individual test methods in their own session/run then I never encounter the problem. I also never get a stack trace or any meaningful debug output just before the Stack overflow occurs. This is the most I've been able to extract out of the test/debug output:
Running/debugging the test project seems to make no difference. I've never been able to get VS to even break on the Stack overflow; this is just bizarre. Using Xunit/.NET Core 3.1. |
"I've been getting this same issue, but it seemingly occurs only when running a whole test project at once; if I try to test each individual test methods in their own session/run then I never encounter the problem." multiple tests are stress loading each other. try running each test with a cpu-stress app. https://learn.microsoft.com/en-us/sysinternals/downloads/cpustres. or, maybe your tests are sharing data. maybe you have static (global) variables. |
Yeah I do have shared static variables, but their values are set in a static constructor and are read only. What's bizarre here is the stack overflow error only occurs when I run the tests in VS or using the |
@mamift - having inconsistent test results is an indication of data corruption. is your static ctor invoked only once for ALL the tests? i would get rid of any static variables. each test should live in its own bubble universe. you are violating this sacred principle. |
@mamift - if you have a multi-threaded code under test - that could also lead to inconsistent test results. but you would be able to reproduce the inconsistency in the test results even when you run a single test. so that is not a prime suspect. [edit] use a cpu-stress-app https://learn.microsoft.com/en-us/sysinternals/downloads/cpustres. load up all cpu's to 100%. then run each test separately. |
After the most recent Visual Studio 2022 update I've started seeing this nearly constantly in one of our solutions (with 421 tests using xUnit). Using .NET 6. I've gone over this entire thread as well as some other discussions I've found. None lead to fixes. When I do get it to run without this error, there's only 1 failure (and that's a not implemented exception for a test I've yet to write). |
try |
How do I get Visual Studio to do that with the test explorer runner? |
just in case this helps someone, at a random time this line started randomly hanging our tests _task = Task.Factory.StartNew(async () => |
I just took a look at the original issue's description. #2261 (comment) |
That is literally what I wrote above as the cause of crash in my case (#2261 (comment)). |
@JBoothUA - With all due respect. your hanging line seems irrelevant to this issue. Not that this issue is actually an issue (I keep saying that there is no issue and we should close it). But your issue is even simpler than this issue. Both your issue and this issue seem to emanate from your (and @xuzhg's) bad threading code. |
Holy moly, that was it. Thanks dude. |
@xuzhg can you please close this issue? Reason: CANNOT REPRODUCE. |
Description
Steps to reproduce
git clone https://github.com/xuzhg/WebApi.git
git checkout -b RoutingBaseForNEtCore30 origin/RoutingBaseForNEtCore30
dotnet --version
run the following command (please replace the following Folder):
dotnet test [YOURLocalClonedFolder]\test\E2ETest\Microsoft.Test.E2E.AspNet.OData\Build.AspNetCore3x\Microsoft.Test.E2E.AspNetCore3x.OData.csproj --logger trx --results-directory C:\BuildAgent\_work\_temp --configuration release --no-build -v diag
result:
Expected behavior
Actual behavior
Environment
Additional Info
If i run the failure test case individually, it can pass:
as:
The text was updated successfully, but these errors were encountered: