Skip to content

DispatcherImpl::isThreadSafe is not thread safe #22855

@benjaminp

Description

@benjaminp

DispatcherImpl::isThreadSafe is mainly used to assert that a piece of code is or isn't running in the event loop thread. However, isThreadSafe is only correct after the thread running the dispatch loop has entered DispatcherImpl::run, which sets the run_tid_ member that isThreadSafe uses. If one thread is about to start DispatcherImpl::run and another thread is testing isThreadSafe, there's technically a data race on the run_tid_ member. This situation probably only happens in tests, where it can lead to flakes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/test flakesstalestalebot believes this issue/PR has not been touched recently

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions