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

Janne Blomqvist <jb at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jb at gcc dot gnu.org

--- Comment #5 from Janne Blomqvist <jb at gcc dot gnu.org> ---
(In reply to Andrew Benson from comment #1)
> Running with -fsanitize=thread (suggested by Tobias) gives:
> 
> ==================
> WARNING: ThreadSanitizer: lock-order-inversion (potential deadlock)
> (pid=9982)
>   Cycle in lock order graph: M26 (0x7f02bb31c340) => M84 (0x7b58002efee0) => 
> M26
> 
>   Mutex M84 acquired here while holding mutex M26 in thread T63:
>     #0 pthread_mutex_lock
> ../../../../gcc-trunk/libsanitizer/sanitizer_common/
> sanitizer_common_interceptors.inc:4148 (libtsan.so.0+0x5095a)
>     #1 __gthread_mutex_lock ../libgcc/gthr-default.h:749 (libgfortran.so.
> 5+0x1e25c9)
>     #2 insert_unit ../../../gcc-trunk/libgfortran/io/unit.c:244 
> (libgfortran.so.5+0x1e25c9)
>     #3 gomp_thread_start ../../../gcc-trunk/libgomp/team.c:123 (libgomp.so.
> 1+0x198a5)
> 
>   Mutex M26 previously acquired by the same thread here:
>     #0 pthread_mutex_lock
> ../../../../gcc-trunk/libsanitizer/sanitizer_common/
> sanitizer_common_interceptors.inc:4148 (libtsan.so.0+0x5095a)
>     #1 __gthread_mutex_lock ../libgcc/gthr-default.h:749 (libgfortran.so.
> 5+0x1e265c)
>     #2 get_gfc_unit ../../../gcc-trunk/libgfortran/io/unit.c:332 
> (libgfortran.so.5+0x1e265c)
>     #3 gomp_thread_start ../../../gcc-trunk/libgomp/team.c:123 (libgomp.so.
> 1+0x198a5)
> 
>   Mutex M26 acquired here while holding mutex M84 in thread T63:
>     #0 pthread_mutex_lock
> ../../../../gcc-trunk/libsanitizer/sanitizer_common/
> sanitizer_common_interceptors.inc:4148 (libtsan.so.0+0x5095a)
>     #1 __gthread_mutex_lock ../libgcc/gthr-default.h:749 (libgfortran.so.
> 5+0x1e336b)
>     #2 close_unit_1 ../../../gcc-trunk/libgfortran/io/unit.c:735 
> (libgfortran.so.5+0x1e336b)
>     #3 gomp_thread_start ../../../gcc-trunk/libgomp/team.c:123 (libgomp.so.
> 1+0x198a5)
> 
>   Mutex M84 previously acquired by the same thread here:
>     #0 pthread_mutex_trylock ../../../../gcc-trunk/libsanitizer/tsan/
> tsan_interceptors_posix.cpp:1246 (libtsan.so.0+0x4340a)
>     #1 __gthread_mutex_trylock ../libgcc/gthr-default.h:758 (libgfortran.so.
> 5+0x1e26f1)
>     #2 get_gfc_unit ../../../gcc-trunk/libgfortran/io/unit.c:380 
> (libgfortran.so.5+0x1e26f1)
>     #3 gomp_thread_start ../../../gcc-trunk/libgomp/team.c:123 (libgomp.so.
> 1+0x198a5)
> 
>   Thread T63 (tid=10047, running) created by main thread at:
>     #0 pthread_create ../../../../gcc-trunk/libsanitizer/tsan/
> tsan_interceptors_posix.cpp:962 (libtsan.so.0+0x5bb22)
>     #1 gomp_team_start ../../../gcc-trunk/libgomp/team.c:839 (libgomp.so.
> 1+0x19eba)
>     #2 main <null> (a.out+0x400ef9)
> 
> SUMMARY: ThreadSanitizer: lock-order-inversion (potential deadlock)
> ../libgcc/
> gthr-default.h:749 in __gthread_mutex_lock
> ==================

FWIW, this is a known problem (don't know if there's a PR for it). As far as
I've been able to see, the problem is that threadsanitizer cannot prove that
the unit locking scheme is correct even though it is.

Of course, it would be nice if we could redesign the locking so that
threadsanitizer would be happy, as then threadsanitizer would be more useful
for us.

Reply via email to