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

Skip cleanup of eventpipe for mono to prevent crashes on shutdown #100938

Merged
merged 3 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
43 changes: 0 additions & 43 deletions src/mono/mono/eventpipe/ep-rt-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -849,49 +849,6 @@ ep_rt_mono_init_finish (void)
mono_error_cleanup (error);
}

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 ();

if (_eventpipe_initialized)
mono_rand_close (_rand_provider);

_rand_provider = NULL;
_eventpipe_initialized = FALSE;

_ep_rt_mono_runtime_initialized = FALSE;

if (_ep_rt_mono_default_profiler_provider) {
mono_profiler_set_runtime_initialized_callback (_ep_rt_mono_default_profiler_provider, NULL);
mono_profiler_set_thread_started_callback (_ep_rt_mono_default_profiler_provider, NULL);
mono_profiler_set_thread_stopped_callback (_ep_rt_mono_default_profiler_provider, NULL);
}
_ep_rt_mono_default_profiler_provider = NULL;
davmason marked this conversation as resolved.
Show resolved Hide resolved

if (_ep_rt_mono_thread_holder_tls_id)
mono_native_tls_free (_ep_rt_mono_thread_holder_tls_id);
_ep_rt_mono_thread_holder_tls_id = 0;

if (_thread_data_tls_id)
mono_native_tls_free (_thread_data_tls_id);
_thread_data_tls_id = 0;

_ep_rt_mono_os_cmd_line_init = MONO_LAZY_INIT_STATUS_NOT_INITIALIZED;
_ep_rt_mono_os_cmd_line = NULL;

_ep_rt_mono_managed_cmd_line_init = MONO_LAZY_INIT_STATUS_NOT_INITIALIZED;
_ep_rt_mono_managed_cmd_line = NULL;

ep_rt_spin_lock_free (&_ep_rt_mono_config_lock);
}

void
EP_CALLBACK_CALLTYPE
EventPipeEtwCallbackDotNETRuntimeRundown (
Expand Down
6 changes: 4 additions & 2 deletions src/mono/mono/eventpipe/ep-rt-mono.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ extern void ep_rt_mono_thread_detach (void);
extern void ep_rt_mono_component_init (void);
extern void ep_rt_mono_init (void);
extern void ep_rt_mono_init_finish (void);
extern void ep_rt_mono_fini (void);
extern bool ep_rt_mono_walk_managed_stack_for_thread (ep_rt_thread_handle_t thread, EventPipeStackContents *stack_contents);
extern bool ep_rt_mono_method_get_simple_assembly_name (ep_rt_method_desc_t *method, ep_char8_t *name, size_t name_len);
extern bool ep_rt_mono_method_get_full_name (ep_rt_method_desc_t *method, ep_char8_t *name, size_t name_len);
Expand Down Expand Up @@ -402,7 +401,10 @@ ep_rt_shutdown (void)
mono_lazy_cleanup (managed_command_line_get_init (), managed_command_line_lazy_clean);
mono_lazy_cleanup (os_command_line_get_init (), os_command_line_lazy_clean);

ep_rt_mono_fini ();
// We were cleaning up resources (mutexes, tls data, etc) here but it races with
// other threads on shutdown. Skipping cleanup to prevent failures. If unloading
// and not leaking these threads becomes a priority we will have to reimplement
// cleanup here.
}

static
Expand Down
Loading