Closed
Description
I've been contributing to NativeAOT port on game consoles by @TheSpydog . With our current project, we are receiving a crash during gen1 GC using .NET 7 preview 7 on an ARM64 platform.
Bootstrap.nss!WKS::WaitLonger(int i) Line 1490 (0x33B9216E00) C++
Bootstrap.nss!WKS::gc_heap::background_mark_phase() Line 34085 (0x33B922AB10) C++
Bootstrap.nss!WKS::gc_heap::gc1() Line 20663 (0x33B9229830) C++
Bootstrap.nss!WKS::gc_heap::bgc_thread_function() Line 35184 (0x33B92402F8) C++
We're unsure if this is an upstream issue or perhaps a misconfiguration of NativeAOT on our side. I've included the info that I was able to find below. Any additional pointers to help diagnose further would be much appreciated.
IsCurrentThreadInCooperativeMode is returning false, triggering the assert in WaitLonger(int i).
bool Thread::IsCurrentThreadInCooperativeMode()
{
#ifndef DACCESS_COMPILE
ASSERT(ThreadStore::GetCurrentThread() == this);
#endif // !DACCESS_COMPILE
return (m_pTransitionFrame == NULL);
}
I think the issue is related to volatile read/write of m_pTransitionFrame in thread.cpp.
void Thread::EnablePreemptiveMode()
{
ASSERT(ThreadStore::GetCurrentThread() == this);
#if !defined(HOST_WASM)
ASSERT(m_pDeferredTransitionFrame != NULL);
#endif
Unhijack();
// set preemptive mode
VolatileStoreWithoutBarrier(&m_pTransitionFrame, m_pDeferredTransitionFrame);
}