Skip to content

Commit

Permalink
Make sure EventPipe streaming thread won't write session->streaming_t…
Browse files Browse the repository at this point in the history
…hread 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 <[email protected]>
  • Loading branch information
github-actions[bot] and lateralusX authored Sep 8, 2021
1 parent a77b391 commit 66c228e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/native/eventpipe/ep-session.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 66c228e

Please sign in to comment.