Fix a race condition between the Watcher thread and the main thread
commitd3a29ff624e0984a40a60dbc1f03ac74b8d03658
authorDerek Mauro <dmauro@google.com>
Wed, 3 Apr 2024 20:21:06 +0000 (3 13:21 -0700)
committerCopybara-Service <copybara-worker@google.com>
Wed, 3 Apr 2024 20:21:58 +0000 (3 13:21 -0700)
tree87b342007dbbb096230f003b1e8b28fa431df0a0
parentec7b38672c04c8af3cfb078214edf6751b841014
Fix a race condition between the Watcher thread and the main thread
during program exit

A race condition exist between the Watcher thread and main(). A case
was found where the Watcher thread does not get execution time before
the main function returns and calls atexit(). At that point the
Watcher thread started runing tls_init() code while the main thread
was shutting down. This resulted in rare crashes and deadlocks.

Fixes #4493
Closes #4494

PiperOrigin-RevId: 621619768
Change-Id: I66f00d8f0f3c37f9937c6d13890f7fa10038256d
googletest/src/gtest-port.cc