https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64484
Bug ID: 64484 Summary: TSAN reports lock-order-inversion in c940006, c940011 and c940012 Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada Assignee: unassigned at gcc dot gnu.org Reporter: bernd.edlinger at hotmail dot de Hi, with my TSAN Ada patch I see a lock-order-inversion in three test cases: ed@w-ed:~/gnu/gcc-test$ TSAN_OPTIONS=second_deadlock_stack=1 ./c940006 ,.,. C940006 ACATS 2.5 15-01-03 21:44:18 ---- C940006 Check external calls of protected functions and procedures. ================== WARNING: ThreadSanitizer: lock-order-inversion (potential deadlock) (pid=21031) Cycle in lock order graph: M14 (0x7fff21661758) => M13 (0x7fff216616e0) => M14 Mutex M13 acquired here while holding mutex M14 in main thread: #0 pthread_mutex_lock ../../../../gcc-trunk/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:2988 (libtsan.so.0+0x000000035456) #1 system__task_primitives__operations__write_lock /home/ed/gnu/gcc-build/gcc/ada/rts/s-taprop.adb:363 (c940006+0x00000040ba07) #2 c940006__B_1__ramp_32__set_local_overloadN.5152 <null> (c940006+0x00000040a5ff) #3 c940006__B_1__ramp_32__set_local_overloadP.5156 <null> (c940006+0x00000040a6e8) #4 _ada_c940006 /home/ed/gnu/gcc-test/c940006.adb:209 (c940006+0x0000004098b6) #5 main /home/ed/gnu/gcc-test/b~c940006.adb:248 (c940006+0x000000403fac) Mutex M14 previously acquired by the same thread here: #0 pthread_mutex_lock ../../../../gcc-trunk/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:2988 (libtsan.so.0+0x000000035456) #1 system__task_primitives__operations__write_lock /home/ed/gnu/gcc-build/gcc/ada/rts/s-taprop.adb:363 (c940006+0x00000040ba07) #2 _ada_c940006 /home/ed/gnu/gcc-test/c940006.adb:209 (c940006+0x0000004098b6) #3 main /home/ed/gnu/gcc-test/b~c940006.adb:248 (c940006+0x000000403fac) Mutex M14 acquired here while holding mutex M13 in main thread: #0 pthread_mutex_lock ../../../../gcc-trunk/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:2988 (libtsan.so.0+0x000000035456) #1 system__task_primitives__operations__read_lock /home/ed/gnu/gcc-build/gcc/ada/rts/s-taprop.adb:407 (c940006+0x00000040ba67) #2 c940006__B_1__ramp_31__downstream_rampsN.5133 <null> (c940006+0x00000040a20d) #3 c940006__B_1__ramp_31__downstream_rampsP.5136 <null> (c940006+0x00000040a2e9) #4 _ada_c940006 /home/ed/gnu/gcc-test/c940006.adb:211 (c940006+0x0000004098cf) #5 main /home/ed/gnu/gcc-test/b~c940006.adb:248 (c940006+0x000000403fac) Mutex M13 previously acquired by the same thread here: #0 pthread_mutex_lock ../../../../gcc-trunk/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:2988 (libtsan.so.0+0x000000035456) #1 system__task_primitives__operations__write_lock /home/ed/gnu/gcc-build/gcc/ada/rts/s-taprop.adb:363 (c940006+0x00000040ba07) #2 _ada_c940006 /home/ed/gnu/gcc-test/c940006.adb:211 (c940006+0x0000004098cf) #3 main /home/ed/gnu/gcc-test/b~c940006.adb:248 (c940006+0x000000403fac) SUMMARY: ThreadSanitizer: lock-order-inversion (potential deadlock) /home/ed/gnu/gcc-build/gcc/ada/rts/s-taprop.adb:363 system__task_primitives__operations__write_lock ================== ==== C940006 PASSED ============================. ThreadSanitizer: reported 1 warnings ed@w-ed:~/gnu/gcc-test$ ed@w-ed:~/gnu/gcc-test$ TSAN_OPTIONS=second_deadlock_stack=1 ./c940011 ,.,. C940011 ACATS 2.5 15-01-03 21:45:26 ---- C940011 Protected Objects created by allocators: external calls via access types. ================== WARNING: ThreadSanitizer: lock-order-inversion (potential deadlock) (pid=7832) Cycle in lock order graph: M15 (0x7d200000bec0) => M14 (0x7d200000bf40) => M15 Mutex M14 acquired here while holding mutex M15 in main thread: #0 pthread_mutex_lock ../../../../gcc-trunk/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:2988 (libtsan.so.0+0x000000035456) #1 system__task_primitives__operations__write_lock /home/ed/gnu/gcc-build/gcc/ada/rts/s-taprop.adb:363 (c940011+0x00000040b4d7) #2 c940011__ramp__set_local_overloadN.5119 <null> (c940011+0x000000409c55) #3 c940011__ramp__set_local_overloadP.5123 <null> (c940011+0x000000409d3f) #4 _ada_c940011 /home/ed/gnu/gcc-test/c940011.adb:165 (c940011+0x00000040998d) #5 main /home/ed/gnu/gcc-test/b~c940011.adb:248 (c940011+0x000000403fac) Mutex M15 previously acquired by the same thread here: #0 pthread_mutex_lock ../../../../gcc-trunk/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:2988 (libtsan.so.0+0x000000035456) #1 system__task_primitives__operations__write_lock /home/ed/gnu/gcc-build/gcc/ada/rts/s-taprop.adb:363 (c940011+0x00000040b4d7) #2 _ada_c940011 /home/ed/gnu/gcc-test/c940011.adb:165 (c940011+0x00000040998d) #3 main /home/ed/gnu/gcc-test/b~c940011.adb:248 (c940011+0x000000403fac) Mutex M15 acquired here while holding mutex M14 in main thread: #0 pthread_mutex_lock ../../../../gcc-trunk/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:2988 (libtsan.so.0+0x000000035456) #1 system__task_primitives__operations__read_lock /home/ed/gnu/gcc-build/gcc/ada/rts/s-taprop.adb:407 (c940011+0x00000040b537) #2 c940011__ramp__next_ramp_overloadN.5138 <null> (c940011+0x00000040a0de) #3 c940011__ramp__next_ramp_overloadP.5141 <null> (c940011+0x00000040a1be) #4 _ada_c940011 /home/ed/gnu/gcc-test/c940011.adb:169 (c940011+0x0000004099dd) #5 main /home/ed/gnu/gcc-test/b~c940011.adb:248 (c940011+0x000000403fac) Mutex M14 previously acquired by the same thread here: #0 pthread_mutex_lock ../../../../gcc-trunk/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:2988 (libtsan.so.0+0x000000035456) #1 system__task_primitives__operations__read_lock /home/ed/gnu/gcc-build/gcc/ada/rts/s-taprop.adb:407 (c940011+0x00000040b537) #2 _ada_c940011 /home/ed/gnu/gcc-test/c940011.adb:169 (c940011+0x0000004099dd) #3 main /home/ed/gnu/gcc-test/b~c940011.adb:248 (c940011+0x000000403fac) SUMMARY: ThreadSanitizer: lock-order-inversion (potential deadlock) /home/ed/gnu/gcc-build/gcc/ada/rts/s-taprop.adb:363 system__task_primitives__operations__write_lock ================== ==== C940011 PASSED ============================. ThreadSanitizer: reported 1 warnings ed@w-ed:~/gnu/gcc-test$ ed@w-ed:~/gnu/gcc-test$ TSAN_OPTIONS=second_deadlock_stack=1 ./c940012 ,.,. C940012 ACATS 2.5 15-01-03 21:46:44 ---- C940012 Check that a protected object can have discriminants. ================== WARNING: ThreadSanitizer: lock-order-inversion (potential deadlock) (pid=26419) Cycle in lock order graph: M15 (0x7d200000bec0) => M14 (0x7d200000bf40) => M15 Mutex M14 acquired here while holding mutex M15 in main thread: #0 pthread_mutex_lock ../../../../gcc-trunk/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:2988 (libtsan.so.0+0x000000035456) #1 system__task_primitives__operations__write_lock /home/ed/gnu/gcc-build/gcc/ada/rts/s-taprop.adb:363 (c940012+0x00000040b7a7) #2 c940012__ramp__set_local_overloadN.5206 <null> (c940012+0x000000409f14) #3 c940012__ramp__set_local_overloadP.5210 <null> (c940012+0x000000409ffe) #4 _ada_c940012 /home/ed/gnu/gcc-test/c940012.adb:163 (c940012+0x000000409baf) #5 main /home/ed/gnu/gcc-test/b~c940012.adb:248 (c940012+0x000000403fac) Mutex M15 previously acquired by the same thread here: #0 pthread_mutex_lock ../../../../gcc-trunk/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:2988 (libtsan.so.0+0x000000035456) #1 system__task_primitives__operations__write_lock /home/ed/gnu/gcc-build/gcc/ada/rts/s-taprop.adb:363 (c940012+0x00000040b7a7) #2 _ada_c940012 /home/ed/gnu/gcc-test/c940012.adb:163 (c940012+0x000000409baf) #3 main /home/ed/gnu/gcc-test/b~c940012.adb:248 (c940012+0x000000403fac) Mutex M15 acquired here while holding mutex M14 in main thread: #0 pthread_mutex_lock ../../../../gcc-trunk/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:2988 (libtsan.so.0+0x000000035456) #1 system__task_primitives__operations__read_lock /home/ed/gnu/gcc-build/gcc/ada/rts/s-taprop.adb:407 (c940012+0x00000040b807) #2 c940012__ramp__next_ramp_overloadN.5199 <null> (c940012+0x00000040a3a4) #3 c940012__ramp__next_ramp_overloadP.5202 <null> (c940012+0x00000040a484) #4 _ada_c940012 /home/ed/gnu/gcc-test/c940012.adb:167 (c940012+0x000000409c0e) #5 main /home/ed/gnu/gcc-test/b~c940012.adb:248 (c940012+0x000000403fac) Mutex M14 previously acquired by the same thread here: #0 pthread_mutex_lock ../../../../gcc-trunk/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:2988 (libtsan.so.0+0x000000035456) #1 system__task_primitives__operations__read_lock /home/ed/gnu/gcc-build/gcc/ada/rts/s-taprop.adb:407 (c940012+0x00000040b807) #2 _ada_c940012 /home/ed/gnu/gcc-test/c940012.adb:167 (c940012+0x000000409c0e) #3 main /home/ed/gnu/gcc-test/b~c940012.adb:248 (c940012+0x000000403fac) SUMMARY: ThreadSanitizer: lock-order-inversion (potential deadlock) /home/ed/gnu/gcc-build/gcc/ada/rts/s-taprop.adb:363 system__task_primitives__operations__write_lock ================== ==== C940012 PASSED ============================. ThreadSanitizer: reported 1 warnings ed@w-ed:~/gnu/gcc-test$