From: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 8 Sep 2021 17:38:57 +0000 (-0700) Subject: Make sure EventPipe streaming thread won't write session->streaming_thread after... X-Git-Tag: accepted/tizen/unified/20220110.054933~189 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=66c228e51827b91434fbb899fb413201d27cc1b6;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Make sure EventPipe streaming thread won't write session->streaming_thread after session free. (#58710) In case where ep_disable is called by a different thread (close IPC command) there was a race between streaming threads setting session->streaming_thread to NULL and IPC command triggering a call to disable_holding_lock and freeing session. Resetting the streaming_thread in streaming thread must happens before it signals its shutdown event to prevent the race. Co-authored-by: lateralusX --- diff --git a/src/native/eventpipe/ep-session.c b/src/native/eventpipe/ep-session.c index 60a5fe0..dc3a259 100644 --- a/src/native/eventpipe/ep-session.c +++ b/src/native/eventpipe/ep-session.c @@ -68,11 +68,10 @@ EP_RT_DEFINE_THREAD_FUNC (streaming_thread) ep_rt_thread_sleep (timeout_ns); } + session->streaming_thread = NULL; ep_rt_wait_event_set (&session->rt_thread_shutdown_event); EP_GCX_PREEMP_EXIT - session->streaming_thread = NULL; - if (!success) ep_disable ((EventPipeSessionID)session);