Fix GVM dispatch for covariant-return async methods (closes #127197)#129481
Fix GVM dispatch for covariant-return async methods (closes #127197)#129481Copilot wants to merge 2 commits into
Conversation
|
Tagging subscribers to this area: @agocke |
ResolveGenericVirtualMethod was passing asyncVariantLookup=Ordinary (default) to FindOrCreateAssociatedMethodDesc. When the resolved vtable slot contained an async-variant or ReturnDroppingThunk MethodDesc, GetParallelMethodDesc(pDefMD, Ordinary) would walk back to the primary thunk instead of the async variant, causing the primary thunk to emit CALLVIRT back to the async-variant slot, which GVM dispatch again resolved to the primary thunk — infinite recursion / stack overflow. Fix: pass pTargetMDBeforeGenericMethodArgs->GetAsyncVariantLookup() so FindOrCreateAssociatedMethodDesc finds the correctly-typed instantiated MD (Async or ReturnDroppingThunk) matching the resolved vtable entry. Co-authored-by: VSadov <8218165+VSadov@users.noreply.github.com>
|
@copilot test failures need to be addressed |
The committed fix in After deep analysis of the dispatch chain:
The logic says this should resolve to |
ResolveGenericVirtualMethodwas passingasyncVariantLookup = Ordinary(the default) toFindOrCreateAssociatedMethodDesc. When the vtable slot resolved to an async-variant orReturnDroppingThunk(RDT)MethodDesc,GetParallelMethodDesc(pDefMD, Ordinary)walked back to the primary thunk instead. The primary thunk then emittedCALLVIRTback to the async-variant slot, which GVM dispatch again resolved to the primary thunk — infinite recursion → stack overflow.The fix is a one-line change in
ResolveGenericVirtualMethod:GetAsyncVariantLookup()returnsAsync,ReturnDroppingThunk, orOrdinarydepending on what the resolved slot holds, ensuringFindOrCreateAssociatedMethodDesccreates the correctly-typed instantiated MD in all three cases.This fix depends on the prerequisite
AsyncVariantLookup::ReturnDroppingThunkenum value,GetAsyncVariantLookup(), the 3-way variant selector inFindOrCreateAssociatedMethodDesc, and thebool → AsyncVariantLookupwidening ofInstMethodHashTable::FindMethodDesc/InstantiatedMethodDesc::FindLoadedInstantiatedMethodDescalready in this PR.TestGenericVirtualMethodis re-enabled.