This is an archive of the discontinued LLVM Phabricator instance.

Fix for pthread_setspecific (TLS and shutdown) problem
ClosedPublic

Authored by jlpeyton on Apr 12 2016, 10:31 AM.

Details

Summary

Some codes that use TLS fail intermittently because one thread tries to write TLS values after the TLS key has been destroyed by another thread. This happens when one thread executes library shutdown (and destroys TLS keys), while another thread starts to execute the TLS key destructor routine. Before this change, the kmp_init_runtime flag was checked before calling pthread_* TLS functions, but this flag is set to FALSE later than the destruction of the TLS keys, which leads to failure. The fix is to check kmp_init_gtid instead, as this flag is unset *before* the destruction of TLS keys.

Diff Detail

Repository
rL LLVM

Event Timeline

jlpeyton updated this revision to Diff 53426.Apr 12 2016, 10:31 AM
jlpeyton retitled this revision from to Fix for pthread_setspecific (TLS and shutdown) problem.
jlpeyton updated this object.
jlpeyton added a reviewer: AndreyChurbanov.
jlpeyton set the repository for this revision to rL LLVM.
jlpeyton added a subscriber: openmp-commits.
AndreyChurbanov accepted this revision.Apr 18 2016, 10:50 AM
AndreyChurbanov edited edge metadata.

LGTM

This revision is now accepted and ready to land.Apr 18 2016, 10:50 AM
This revision was automatically updated to reflect the committed changes.