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
Hitting this assert in the repro from #110607 sometimes.
The stack is (line numbers are for release/9.0)
WinUIAppTest.exe!Assert(const char * expr, const char * file, unsigned int line_num, const char * message) Line 35 C++
[Inline Frame] WinUIAppTest.exe!Thread::InlineTryFastReversePInvoke(ReversePInvokeFrame *) Line 130 C++
WinUIAppTest.exe!RhpReversePInvoke(ReversePInvokeFrame * pFrame) Line 1317 C++
WinUIAppTest.exe!S_P_CoreLib_System_Runtime_InteropServices_TrackerObjectManager__GCStopCollection() Line 173 Unknown
WinUIAppTest.exe!RestrictedCallouts::InvokeGcCallouts(GcRestrictedCalloutKind eKind, unsigned int uiCondemnedGeneration) Line 195 C++
WinUIAppTest.exe!GCToEEInterface::GcDone(int condemned) Line 161 C++
WinUIAppTest.exe!WKS::gc_heap::do_post_gc() Line 50870 C++
WinUIAppTest.exe!WKS::gc_heap::bgc_thread_function() Line 39957 C++
WinUIAppTest.exe!WKS::gc_heap::bgc_thread_stub(void * arg) Line 37744 C++
Hopefully this is not a product issue, just an assert that needs to be tweaked.
Before that IsDoNotTriggerGcSet was used in these cases:
Transient use by exception handling to go through code that is not GC-safe, but that scenario is relatively trivial and does not involve PInvokes or reverse PInvokes.
Another use was by GC threads while EE is stopped. In this case we could do reverse pinvokes and returns from them. It was special-cased and transitions are basically noops - ignoring the coop mode of the thread and not checking if suspension is requested. All that is meaningless anyways - when EE is stopped and blocking GC is already running.
Now we have a scenario when background threads call [UnmanagedCallersOnly] methods from GC callouts.
Since the scenario is limited to BGC threads and specific callouts, it may still be ok to do, depending on what those callouts do. - All the rules of what GC callouts cannot do would still apply, but otherwise we could ignore the coop state of a IsDoNotTriggerGcSet thread when doing a reverse PInvoke.
The GC callouts is a relatively fragile pattern, and it is hard to think of all the consequences, but I think we may be able to get away with it in this case.
Assuming we do not see any other troubles besides this assert, I think relaxing the assert to ASSERT(IsGcSpecial()); , just to be sure this is not happening with some random thread, could be a sufficient "fix".
Hitting this assert in the repro from #110607 sometimes.
The stack is (line numbers are for release/9.0)
Hopefully this is not a product issue, just an assert that needs to be tweaked.
We set DoNotTriggerGC here:
runtime/src/coreclr/nativeaot/Runtime/RestrictedCallouts.cpp
Lines 180 to 182 in 1622f51
And then we go into the assert path here:
runtime/src/coreclr/nativeaot/Runtime/thread.inl
Lines 194 to 205 in 1622f51
Cc @VSadov for opinion
The text was updated successfully, but these errors were encountered: