-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Stop unloading the profiler on shutdown to prevent segfaults on background threads #26762
Conversation
src/vm/proftoeeinterfaceimpl.cpp
Outdated
@@ -10235,11 +10235,15 @@ HCIMPL2(EXTERN_C void, ProfileEnter, UINT_PTR clientData, void * platformSpecifi | |||
|
|||
#ifdef PROFILING_SUPPORTED | |||
|
|||
// We might have already torn down the profiler, if so we need to abort. | |||
if (g_profControlBlock.curProfStatus.Get() != kProfStatusActive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the profiler is torn down right after we do this check, but before we actually call it below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there are all sorts of races here. I realize now that even the check can race, depending on the order of events g_profControlBlock.pProfInterface
could be set to null after g_profControlBlock.pProfInterface.Load() == NULL
and then g_profControlBlock.pProfInterface->GetEnterHook() == NULL
would AV. I need to rework this entirely.
Looking at why this happens on Linux and not Windows it's because we don't set The only other options are to continue crashing sometimes or to put expensive synchronization on a hot path in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, sorry I missed this earlier
Fixes #26687
On Linux we were seeing profilers crash in ELT hooks because the profiler would be shut down before all managed threads had exited. These checks will prevent slow path ELT from crashing, profiler vendors will have to deal with fast path ELT calls that come in after the profiler is shut down.