Skip to content

Commit 043fcd5

Browse files
[release/10.0] Fix ProfileEnter when called on a foreign thread (#119349)
* Fix ProfileEnter when called on a foreign thread When ProfileEnter is called on a foreign thread that the runtime has not seen yet, which can happen for UnmanagedCallersOnly marked methods, it crashes in the GCX_COOP_THREAD_EXISTS(GET_THREAD()); That was left in by accident in my change I've made a long time ago and should not be there. This change removes that switch, we switch to cooperative mode later in the ProfileEnter and setup the thread for runtime before that. Close #115617 * Make ProfileLeave look the same --------- Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
1 parent c2afc88 commit 043fcd5

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/coreclr/vm/proftoeeinterfaceimpl.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10666,9 +10666,7 @@ void __stdcall ProfilerUnmanagedToManagedTransitionMD(MethodDesc *pMD,
1066610666
// These do a lot of work for us, setting up Frames, gathering arg info and resolving generics.
1066710667
//*******************************************************************************************
1066810668

10669-
HCIMPL2_RAW(EXTERN_C void, ProfileEnter, UINT_PTR clientData, void * platformSpecificHandle)
10670-
GCX_COOP_THREAD_EXISTS(GET_THREAD());
10671-
HCIMPL_PROLOG(ProfileEnter)
10669+
HCIMPL2(EXTERN_C void, ProfileEnter, UINT_PTR clientData, void * platformSpecificHandle)
1067210670
{
1067310671
FCALL_CONTRACT;
1067410672

@@ -10844,12 +10842,12 @@ HCIMPL_PROLOG(ProfileEnter)
1084410842
}
1084510843
HCIMPLEND
1084610844

10847-
HCIMPL2_RAW(EXTERN_C void, ProfileLeave, UINT_PTR clientData, void * platformSpecificHandle)
10848-
GCX_COOP();
10849-
HCIMPL_PROLOG(ProfileLeave)
10845+
HCIMPL2(EXTERN_C void, ProfileLeave, UINT_PTR clientData, void * platformSpecificHandle)
1085010846
{
1085110847
FCALL_CONTRACT;
1085210848

10849+
GCX_COOP();
10850+
1085310851
#ifdef PROFILING_SUPPORTED
1085410852

1085510853
#ifdef PROF_TEST_ONLY_FORCE_ELT

0 commit comments

Comments
 (0)