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

Cherry pick PR #715: Fix gtest multithread crash #743

Merged
merged 1 commit into from
Jun 27, 2023

Commits on Jun 27, 2023

  1. This change allows the use of GoogleTest's ASSERT() and EXPECT() macr…

    …os (#715)
    
    on multiple threads. The failures will be correctly reported and no
    longer crashes the app.
    
    When GoogleTest is used in multi-thread mode (i.e. its macros are used
    on thread other than the main thread), it may crash as
    GetTestPartResultReporterForCurrentThread() returns nullptr on a forked
    thread.
    
    This is due to that the ThreadLocal class in our GTEST_OS_STARBOARD
    implementation doesn't return the default value on newly created threads
    The ThreadLocal ctor accepts a default value of T to be returned on a
    thread where the thread local value hasn't been overridden.
    The existing implementation incorrectly returns T() on a new thread
    where the value has never been set. When T is a pointer, T() is nullptr
    and causes crash when dereferenced.
    
    Now the default value to ThreadLocal ctor is stored and a copy of it
    will be returned on a new thread when the thread local value hasn't been
    set. This ensures that GetTestPartResultReporterForCurrentThread()
    returns the correct TestPartResultReporterInterface*, and failures of
    GoogleTest's ASSERT and EXPECT macros on a different thread will be
    correctly reported and no longer crashes the app.
    
    b/230877781
    
    Change-Id: Ibb5ced5611593092d6065af4474027404a783caa
    (cherry picked from commit 0c9c2cf)
    WeiChungChang authored and anonymous1-me committed Jun 27, 2023
    Configuration menu
    Copy the full SHA
    f21ee33 View commit details
    Browse the repository at this point in the history