This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Fix spurious failures in the thread detach test on Windows
ClosedPublic

Authored by mstorsjo on Jul 7 2021, 2:12 PM.

Details

Summary

Make sure that the detached thread has started up before exiting
the process.

If the detached thread hasn't started up at all, and the main thread
exists, global data structures in the process are torn down, which
then can cause crashes when the thread starts up late after required
mutexes have been destroyed. (In particular, the mutex used internally
in _Init_thread_header, which is used in the intialization of
thread_local_data()::p, can cause crashes if the main thread already
has finished and progressed far with destruction.)

Diff Detail

Event Timeline

mstorsjo requested review of this revision.Jul 7 2021, 2:12 PM
mstorsjo created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJul 7 2021, 2:12 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne accepted this revision.Jul 7 2021, 2:16 PM

Thanks for fixing!

libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp
89

Can you add a comment?

This revision is now accepted and ready to land.Jul 7 2021, 2:16 PM
mstorsjo updated this revision to Diff 357075.Jul 7 2021, 2:19 PM

Added a comment.