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

fix(profiling): fix data race when accessing span for thread #11167

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Oct 24, 2024

  1. fix(profiling): fix data race when accessing span for thread

    The ThreadSpanLinks singleton holds the active span (if one exists) for
    a given thread ID. The get_active_span_from_thread_id member function
    returns a pointer to the active span for a thread. The link_span member
    function sets the active span for a thread. get_active_span_from_thread_id
    accesses the map of spans under a mutex, but returns the pointer after
    releasing the mutex, meaning link_span can modify the members of the
    Span while the caller of get_active_span_from_thread_id is reading them.
    
    Fix this by returning a copy of the Span. Use a std::optional to wrap
    the return value of get_active_span_from_thread_id, rather than
    returning a pointer. We want to tell whether or not there actually was a
    span associated with the thread, but returning a pointer would require
    us to heap allocate the copy of the Span.
    nsrip-dd committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    dd868ee View commit details
    Browse the repository at this point in the history