From: Thomas Koenig <tkoenig@netcologne.de>
To: Janne Blomqvist <blomqvist.janne@gmail.com>
Cc: "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [patch, libfortran] Fix thead sanitizer issue with libgfortran
Date: Fri, 29 Sep 2017 18:53:00 -0000 [thread overview]
Message-ID: <fa7466a3-3589-27b8-b924-1b0c35ee60f9@netcologne.de> (raw)
In-Reply-To: <CAO9iq9F4U4S85ar8Cy=34d5tp55KdJmDMuWU+pcDjGZZqcXAWQ@mail.gmail.com>
Am 29.09.2017 um 10:03 schrieb Janne Blomqvist:
>
> 1) I'm confused why fbuf_destroy is modified. The fbuf structure is
> part of gfc_unit, and should be accessed with the same locking rules
> as the rest of the gfc_unit components. When closing the unit, I think
> the same should apply here, no?
It is to avoid a data race for
program main
use omp_lib
!$OMP PARALLEL NUM_THREADS(2)
call file_open(OMP_get_thread_num())
!$OMP END PARALLEL
contains
recursive subroutine file_open(i)
integer :: i
integer :: nunit
nunit = i + 20
write (nunit,*) 'asdf'
end subroutine file_open
end program main
which leads to
Read of size 4 at 0x7b580000ff30 by main thread (mutexes: write M16):
#0 close_unit_1 ../../../trunk/libgfortran/io/unit.c:699
(libgfortran.so.5+0x000000283ba6)
#1 _gfortrani_close_units ../../../trunk/libgfortran/io/unit.c:767
(libgfortran.so.5+0x000000283f59)
#2 cleanup ../../../trunk/libgfortran/runtime/main.c:113
(libgfortran.so.5+0x00000001fe22)
#3 _dl_fini <null> (ld-linux-x86-64.so.2+0x00000000fb62)
Previous write of size 4 at 0x7b580000ff30 by thread T1 (mutexes:
write M17):
#0 finalize_transfer ../../../trunk/libgfortran/io/transfer.c:3934
(libgfortran.so.5+0x000000281aa1)
#1 _gfortran_st_write_done
../../../trunk/libgfortran/io/transfer.c:4125
(libgfortran.so.5+0x000000281e35)
#2 file_open.3528 <null> (a.out+0x000000400c1b)
#3 MAIN__._omp_fn.0 <null> (a.out+0x000000400d27)
#4 gomp_thread_start ../../../trunk/libgomp/team.c:120
(libgomp.so.1+0x00000001756f)
Note that not all problems with implicit close at the end are resolved
so far, but that is a different problem.
> 2) I think the mutex init stuff can remain in insert_unit, just the
> locking needs to move out and below freeing unit_lock like you have
> done.
I can change that one easily.
Any other comments?
Regards
Thomas
next prev parent reply other threads:[~2017-09-29 18:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-28 17:29 Thomas Koenig
2017-09-29 6:03 ` Thomas Koenig
2017-09-29 8:04 ` Janne Blomqvist
2017-09-29 18:53 ` Thomas Koenig [this message]
2017-10-01 7:42 ` Janne Blomqvist
2017-10-01 9:02 Bernd Edlinger
2017-10-01 13:41 ` Thomas Koenig
2017-10-01 14:23 ` Bernd Edlinger
2017-10-01 16:54 ` Thomas Koenig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fa7466a3-3589-27b8-b924-1b0c35ee60f9@netcologne.de \
--to=tkoenig@netcologne.de \
--cc=blomqvist.janne@gmail.com \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).