Skip to content

Update docs: assertions are thread-safe on desktop Windows - #5103

Open
cindykrafft wants to merge 1 commit into
google:mainfrom
cindykrafft:docs-windows-thread-safety
Open

cindykrafft wants to merge 1 commit into
google:mainfrom
cindykrafft:docs-windows-thread-safety

Conversation

@cindykrafft

Copy link
Copy Markdown

Fixes #4769

The primer's "Known Limitations" section says it is unsafe to use assertions from two threads concurrently on systems without pthreads "(e.g. Windows)". docs/advanced.md has two similar notes ("Assertions from multiple threads are currently not supported on Windows."), one after the {ASSERT|EXPECT}_NO_FATAL_FAILURE example and one after the EXPECT_{NON}FATAL_FAILURE_ON_ALL_THREADS macros.

These statements are outdated:

  • gtest-port.h defines GTEST_IS_THREADSAFE for desktop Windows. The condition includes defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_PHONE) && !defined(GTEST_OS_WINDOWS_RT).
  • gtest-port.cc provides Windows implementations of Mutex, ThreadLocal and ThreadWithParam.
  • The tests that exercise assertions from multiple threads are guarded by GTEST_IS_THREADSAFE, so they are also built on desktop Windows. Examples are ExpectFailureWithThreadsTest and the concurrent SCOPED_TRACE test in googletest-output-test_.cc, and the threading tests in gtest_stress_test.cc and googletest-port-test.cc.

This PR changes documentation only:

  • The primer now says the implementation is thread-safe where pthreads is available and on desktop Windows, and unsafe on other systems.
  • The two Windows-specific notes are removed from advanced.md.

@google-cla

google-cla Bot commented Sep 23, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

The primer's Known Limitations section and two notes in advanced.md say
that using assertions from multiple threads is unsafe or unsupported on
Windows. That is outdated: gtest-port.h defines GTEST_IS_THREADSAFE for
desktop Windows (excluding Windows Phone and Windows RT), gtest-port.cc
provides Windows implementations of Mutex and ThreadLocal, and the
multi-threaded assertion tests guarded by GTEST_IS_THREADSAFE are built
there.

Fixes google#4769

Claude-Session: https://claude.ai/code/session_01X59fWmqnA4Nmb9rggkTP7n
@cindykrafft
cindykrafft force-pushed the docs-windows-thread-safety branch from 405f0e6 to e0c99dd Compare September 23, 2026 21:09

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Docs say gtest isn't threadsafe on windows, but implementation disagrees

1 participant