From 5889b18df8ab5b2e90b9ec595d205a86681a813b Mon Sep 17 00:00:00 2001 From: David Mason Date: Tue, 5 Mar 2024 13:11:37 -0800 Subject: [PATCH] Skip EventPipe cleanup on mono unless runtime is shutting down --- src/mono/mono/eventpipe/ep-rt-mono.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mono/mono/eventpipe/ep-rt-mono.c b/src/mono/mono/eventpipe/ep-rt-mono.c index 9b9f9e34c4bce2..0aa3518df7af77 100644 --- a/src/mono/mono/eventpipe/ep-rt-mono.c +++ b/src/mono/mono/eventpipe/ep-rt-mono.c @@ -852,6 +852,11 @@ ep_rt_mono_init_finish (void) void ep_rt_mono_fini (void) { + // Avoid cleaning up resources to prevent cleaning up out from under running + // threads. + if (!mono_runtime_is_shutting_down ()) + return; + ep_rt_mono_runtime_provider_fini (); ep_rt_mono_profiler_provider_fini ();