https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66756
--- Comment #11 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- Created attachment 42250 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42250&action=edit Proposed patch This patch is an attempt at getting rid of the lock-order inversion. It seems to do the right thing, and survives both regression-testing and the thread sanitizer. It is not yet complete (comments are not adjusted). I would be grateful if somebody had a way to stress-test it.