OSDN Git Service

[libcxx testing] Fix UB in tests for std::lock_guard
authorIgor Kudrin <ikudrin@accesssoftek.com>
Thu, 14 Jan 2021 08:03:44 +0000 (15:03 +0700)
committerIgor Kudrin <ikudrin@accesssoftek.com>
Fri, 15 Jan 2021 09:11:45 +0000 (16:11 +0700)
commit78036360573c35ea9e6a697d2eed92db893b4850
tree9d4aef4c3e9e50c8bcb721718f90edf01b502735
parent89e84dec1879417fb7eb96edaa55dac7eca204ab
[libcxx testing] Fix UB in tests for std::lock_guard

If mutex::try_lock() is called in a thread that already owns the mutex,
the behavior is undefined. The patch fixes the issue by creating another
thread, where the call is allowed.

Differential Revision: https://reviews.llvm.org/D94656
libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp
libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp