https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100371
Bug ID: 100371 Summary: Fortran asynchronous I/O: ASAN (memory leak) + TASN (potential dead lock) warning with libgomp.fortran/async_io_*.f90 Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: jb at gcc dot gnu.org, jvdelisle at gcc dot gnu.org Depends on: 100352 Target Milestone: --- Follow up to PR100352 Shows up in GCC 10 and mainline/12 when running libgomp.fortran/async_io_*.f90 with "gfortran -fopenmp" and ... (A) -fsanitize=thread WARNING: ThreadSanitizer: lock-order-inversion (potential deadlock) (pid=2980290) Mutex M25 acquired here while holding mutex M24 in main thread: #2 insert_unit ../../../repos/gcc/libgfortran/io/unit.c:244 LOCK (&u->lock); Mutex M24 previously acquired by the same thread here: #2 get_gfc_unit ../../../repos/gcc/libgfortran/io/unit.c:332 LOCK (&unit_lock); Mutex M24 acquired here while holding mutex M25 in main thread: #2 close_unit_1 ../../../repos/gcc/libgfortran/io/unit.c:734 LOCK (&unit_lock) Mutex M25 previously acquired by the same thread here: #2 get_gfc_unit ../../../repos/gcc/libgfortran/io/unit.c:380 TRYLOCK (&p->lock) * * * (B) -fsanitize=address / -fsanitize=leak * Direct leak of 80 byte(s) in 1 object(s) allocated from: #1 0x7ff684a15c54 in _gfortrani_enqueue_done_id ../../../repos/gcc/libgfortran/io/async.c:289 which is: enqueue_done_id (async_unit *au, enum aio_do type) ... transfer_queue *tq = calloc (sizeof (transfer_queue), 1); ... au->tail->next = tq; and should get freed in async_io (void *arg) which looks okay. * And I see a bunch of: #1 0x7f3da3491bb8 in _gfortrani_xmalloc ../../../repos/gcc/libgfortran/runtime/memory.c:38 (xmalloc is used throughout libgfortran/io/*.c) (C) On the other hand, valgrind shows: All heap blocks were freed -- no leaks are possible thus (B) might be a false positive. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100352 [Bug 100352] [11/12 Regression] libgomp.fortran/async_io_1.f90 -O0 execution test