[Bug libfortran/66756] libgfortran: ThreadSanitizer: lock-order-inversion

tkoenig at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Sep 25 18:10:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66756

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING

--- Comment #6 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
I think the current behavior is correct, only that the thread
sanitizer does not realize it.

From the comment in unit.c:

   Therefore to avoid deadlocks, it is forbidden
   to acquire unit's private locks while holding UNIT_LOCK, except
   for freshly created units (where no other thread can get at their
   address yet) or when using just trylock rather than lock operation.

... and this appears to be exactly what is happening there.

This makes debugging thread-related problems in libgfortran
somewhat harder, so I'm not sure what is the best course.

Should we try to "fix" this? It should be possible to do
file opening under UNIT_LOCK, that should not be a serious
performance bottleneck. OTOH, the current code seems OK, so
it could be a case of "If it ain't broke, don't fix it".

Opinions?


More information about the Gcc-bugs mailing list