You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Test failure System.Runtime.InteropServices.HandleCollectorTests.TestHandleCollector #66571
This might not be only JitStress (I'm seeing intermittent repros in some PR failures in the runtime pipeline), but JitStress might be the best way to repro it
High limit handle did not trigger a GC
Expected: True
Actual: False
Stack trace
at System.Runtime.InteropServices.HandleCollectorTests.TestHandleCollector() in /_/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/HandleCollectorTests.cs:line 144
System.Runtime.InteropServices.HandleCollectorTests.TestHandleCollector [FAIL]
High limit handle did not trigger a GC: 21 < 21
Expected: True
Actual: False
Stack Trace:
@elinor-fung Thanks for keeping an eye on this. The new logging is very interesting. Based on the above log output there is something odd going on here. The HighLimitSize is hardcoded to 100000 so I would expect there to always be at least 1 additional collected object, but clearly that is not occurring under some scenario. I can think of three possible scenarios, others are welcome.
The "High limit" loop wasn't run. The JIT elided it entirely or some other optimization caused it to not execute any iterations.
The GC didn't allocate new memory for each iteration for some reason and reused existing object instances. This could mean the "collected" count didn't change - I don't know if that is possible.
Some combination of (1) and (2) around a JIT optimization and the GC doing what it is told that changes how this is expected to run.
The ctor for HandleLimitTester is doing all the right things in my mind:
I'm not really sure what is occurring, and I've been unable to reproduce this locally under any DOTNET_ variable combination. Perhaps @jkotas or @Maoni0 could help educate me on what could be happening here.
This test can be running together with all other System.Runtime.InteropServices tests. Those other tests can be allocating and triggering GCs (ie altering the global state that this test asserts are based on). Is the logic of the test robust against that?
Yes, I believe so. All we are attempting to validate is that the sum of GC.CollectionCount(0) + GC.CollectionCount(1) + GC.CollectionCount(2) after the above loop is greater than the same computed sum before the loop. The test is arguably not that useful in a situation where multiple tests are running so it is odd that it fails at all since we simply need 1 additional object to be collected for the test to pass.
Let me confirm again the logic in HandleCollector.Add() and confirm that GC.Collect() will be called more than once.
High limit handle did not trigger a GC: 41 < 41
Expected: True
Actual: False
Stack trace
at System.Runtime.InteropServices.HandleCollectorTests.TestHandleCollector() in /_/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/HandleCollectorTests.cs:line 153
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.RuntimeMethodInfo.InvokeNonEmitUnsafe(Object obj, IntPtr* arguments, Span`1 argsForTemporaryMonoSupport, BindingFlags invokeAttr) in /_/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.CoreCLR.cs:line 383
I finally see what is going on here. This is a classic lack of memory pressure and the GC is making the right call and saying: "leave me alone". I am working on a fix to provide the needed pressure.
Activity
jkoritzinsky commentedon Mar 15, 2022
This might not be only JitStress (I'm seeing intermittent repros in some PR failures in the runtime pipeline), but JitStress might be the best way to repro it
VincentBu commentedon Mar 23, 2022
Failed again in: runtime-coreclr libraries-jitstress 20220322.1
Failed test:
Error message:
adamsitnik commentedon Mar 28, 2022
Hit again in https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-heads-main-d38cf73ba255498fa4/System.Runtime.InteropServices.Tests/1/console.1e36f4c8.log?sv=2019-07-07&se=2022-04-14T09%3A06%3A23Z&sr=c&sp=rl&sig=uDZFbVyRZK5cDOI9bm1CaZmEqIOWIiXmDLL1ex3Ac9M%3D
lewing commentedon Mar 29, 2022
hit again in #67289 https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-67289-merge-a849d3ef657e41ec85/System.Runtime.InteropServices.Tests/1/console.ca03e5cf.log?sv=2019-07-07&se=2022-04-18T13%3A35%3A45Z&sr=c&sp=rl&sig=YwnVzH2lC%2Bc4k6tulsxVOwo8M%2FewKh53GBQgbOvLWfc%3D
VincentBu commentedon Apr 6, 2022
Failed again in: runtime-coreclr libraries-jitstress 20220405.1
Failed test:
Error message:
kouvel commentedon Apr 7, 2022
Hit again in https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-67160-merge-fce57385286b4acdbd/System.Runtime.InteropServices.Tests/1/console.51df3830.log?sv=2019-07-07&se=2022-04-27T01%3A23%3A31Z&sr=c&sp=rl&sig=HGoNjqy5wdwOJiN%2B4k9dooAvVHHVn7myC2nYC5cshT4%3D
VincentBu commentedon Apr 14, 2022
Failed again in: runtime-coreclr libraries-jitstress 20220413.1
Failed test:
Error message:
2 remaining items
elinor-fung commentedon Apr 26, 2022
@AaronRobinsonMSFT it looks like this is still happening
Console log
13 hits in the past five days after #68285 went in: https://runfo.azurewebsites.net/search/tests/?q=started%3A%7E5+definition%3Aruntime+name%3ATestHandleCollector
AaronRobinsonMSFT commentedon Apr 26, 2022
@elinor-fung Thanks for keeping an eye on this. The new logging is very interesting. Based on the above log output there is something odd going on here. The
HighLimitSizeis hardcoded to100000so I would expect there to always be at least 1 additional collected object, but clearly that is not occurring under some scenario. I can think of three possible scenarios, others are welcome.runtime/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/HandleCollectorTests.cs
Lines 141 to 145 in 2ea67f1
The GC didn't allocate new memory for each iteration for some reason and reused existing object instances. This could mean the "collected" count didn't change - I don't know if that is possible.
Some combination of (1) and (2) around a JIT optimization and the GC doing what it is told that changes how this is expected to run.
The ctor for
HandleLimitTesteris doing all the right things in my mind:runtime/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/HandleCollectorTests.cs
Lines 160 to 165 in 2ea67f1
I'm not really sure what is occurring, and I've been unable to reproduce this locally under any
DOTNET_variable combination. Perhaps @jkotas or @Maoni0 could help educate me on what could be happening here.jkotas commentedon Apr 26, 2022
This test can be running together with all other System.Runtime.InteropServices tests. Those other tests can be allocating and triggering GCs (ie altering the global state that this test asserts are based on). Is the logic of the test robust against that?
AaronRobinsonMSFT commentedon Apr 26, 2022
Yes, I believe so. All we are attempting to validate is that the sum of
GC.CollectionCount(0) + GC.CollectionCount(1) + GC.CollectionCount(2)after the above loop is greater than the same computed sum before the loop. The test is arguably not that useful in a situation where multiple tests are running so it is odd that it fails at all since we simply need 1 additional object to be collected for the test to pass.Let me confirm again the logic in
HandleCollector.Add()and confirm thatGC.Collect()will be called more than once.VincentBu commentedon Apr 28, 2022
Failed again in: runtime-coreclr libraries-jitstress 20220427.1
Failed test:
Error message:
AaronRobinsonMSFT commentedon Apr 28, 2022
I finally see what is going on here. This is a classic lack of memory pressure and the GC is making the right call and saying: "leave me alone". I am working on a fix to provide the needed pressure.