[Bug libstdc++/122683] In unique_lock.h unlock() routine, _M_owns is accessed without lock
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Nov 14 10:41:09 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122683
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think it's not a false positive, but it's a bug in the user code not in
std::unique_lock. I told the reporter this when they asked for an account.
It's safe to access a std::mutex from multiple threads concurrently, but it's
not safe to access a single std::unique_lock concurrently. Each thread needs to
create its own std::unique_lock to lock/unlock the mutex.
More information about the Gcc-bugs
mailing list