Skip to content
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

GC stress fix for reverse pinvoke stubs #37432

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/coreclr/src/vm/gccover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,20 @@ BOOL OnGcCoverageInterrupt(PCONTEXT regs)
return TRUE;
}

// If the thread is in preemptive mode then we must be in a
// PInvoke stub, a method that has an inline PInvoke frame,
// or be in a reverse PInvoke stub that's about to return.
//
// The PInvoke cases should should properly report GC refs if we
// trigger GC here. But a reverse PInvoke stub may over-report
// leading to spurious failures, as we would not normally report
// anything for this method at this point.
if (!pThread->PreemptiveGCDisabled() && pMD->HasUnmanagedCallersOnlyAttribute())
{
RemoveGcCoverageInterrupt(instrPtr, savedInstrPtr);
return TRUE;
}

#if defined(USE_REDIRECT_FOR_GCSTRESS) && !defined(TARGET_UNIX)
// If we're unable to redirect, then we simply won't test GC at this
// location.
Expand Down