[patch, libfortran] Fix thead sanitizer issue with libgfortran

Thomas Koenig tkoenig@netcologne.de
Sun Oct 1 13:41:00 GMT 2017


Am 01.10.2017 um 10:59 schrieb Bernd Edlinger:
> maybe there is a way how you could explicitly join
> all running threads?

Yes, that seems to do the trick. Thanks!

Here is a patch which appears to work. It does hit a snag with static
linking, though, because it calls __gthread_self (), and that causes
a segfault with -static :-(.

The test case in question is static_linking_1.f.

This appears to be a general problem, and has  been discussed
before, for example in
https://gcc.gnu.org/ml/gcc-help/2010-05/msg00029.html .

What would be the best way to proceed? Modify the behavior of -static
with gfortran?

Regards

	Thomas

2017-10-01  Thomas Koenig  <tkoenig@gcc.gnu.org> 

 

         PR fortran/66756 

         PR fortran/82378 

         * io/io.h: Add field th to gfc_unit. Add prototypes for 

         lock_unit and trylock_unit. 

         * io/unit.c (insert_unit): Do not create lock and lock, move to 

         (gfc_get_unit): here; lock after insert_unit has succeded. 

         Use lock_unit and trylock_unit instead of __gthread_mutex_lock 

         and __gthread_mutex_trylock. 

         (init_units): Do not unlock unit locks for stdin, stdout and 

         stderr. 

         (lock_unit): New function. 

         (trylock_unit): New function. 

         (close_units): If a unit still has a lock, wait for the 

         completion of the corresponding thread. 

         * io/unix.c (find_file): Use lock_unit and trylock_unit instead 

         of __gthread_mutex_lock and __gthread_mutex_trylock. 

         (flush_all_units): Likewise. 


2017-10-01  Thomas Koenig  <tkoenig@gcc.gnu.org>

         PR fortran/66756
         PR fortran/82378
         * gfortran.dg/openmp-close.f90: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p6.diff
Type: text/x-patch
Size: 6115 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20171001/d0850541/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openmp-close.f90
Type: text/x-fortran
Size: 247 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20171001/d0850541/attachment-0001.bin>


More information about the Fortran mailing list