http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57641
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> --- It's undefined behaviour because you try to lock the same mutex twice in the same thread, see my testcase for a well-defined way to do it, calling try_lock_until in a new thread.