public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Thomas Koenig <tkoenig@netcologne.de>
To: fortran@gcc.gnu.org, gcc-patches <gcc-patches@gcc.gnu.org>,
	Janne Blomqvist <blomqvist.janne@gmail.com>
Subject: Re: [PATCH] libgfortran: Fix and simplify IO locking [PR92836]
Date: Mon, 17 Feb 2020 22:33:00 -0000	[thread overview]
Message-ID: <59c43ebb-ba4a-1703-4669-690c5a0c6c8e@netcologne.de> (raw)
In-Reply-To: <20200131133753.29995-1-blomqvist.janne@gmail.com>

Hi Janne,

> Simplify IO locking in libgfortran.  The new IO implementation avoids
> accessing units without locks, as seen in PR 92836.  It also avoids
> lock inversion (except for a corner case wrt namelist query when
> reading from stdin and outputting to stdout), making it easier to
> verify correctness with tools like valgrind or threadsanitizer.  It is
> also simplified as the waiting and closed variables are not needed
> anymore, making it easier to understand and analyze.
> 
> Regtested on x86_64-pc-linux-gnu, Ok for master?

Sorry it took me so long to actually look at this. The patch for
PR 93599 took a bit longer than anticipated...

With your patch on top of the one I just submitted, I get
valgrind errors for the asynchronous I/O tests:

$ gfortran -g async_io_1.f90 -pthread
$ valgrind --tool=drd ./a.out
==22685== drd, a thread error detector
==22685== Copyright (C) 2006-2017, and GNU GPL'd, by Bart Van Assche.
==22685== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==22685== Command: ./a.out
==22685==
==22685== Destroying locked mutex: mutex 0x60708f0, recursion count 1, 
owner 1.
==22685==    at 0x4C37B65: pthread_mutex_destroy_intercept 
(drd_pthread_intercepts.c:865)
==22685==    by 0x4C37B65: pthread_mutex_destroy 
(drd_pthread_intercepts.c:875)
==22685==    by 0x50A6CAE: __gthread_mutex_destroy (gthr-default.h:740)
==22685==    by 0x50A6CAE: destroy_unit_mutex (unit.c:253)
==22685==    by 0x50A6CAE: close_unit_1 (unit.c:732)
==22685==    by 0x5091E67: _gfortran_st_close (close.c:108)
==22685==    by 0x4011D3: MAIN__ (async_io_1.f90:25)
==22685==    by 0x401AA9: main (async_io_1.f90:48)
==22685== mutex 0x60708f0 was first observed at:
==22685==    at 0x4C37FD5: pthread_mutex_lock_intercept 
(drd_pthread_intercepts.c:885)
==22685==    by 0x4C37FD5: pthread_mutex_lock (drd_pthread_intercepts.c:898)
==22685==    by 0x50A6039: __gthread_mutex_lock (gthr-default.h:749)
==22685==    by 0x50A6039: insert_unit (unit.c:241)
==22685==    by 0x50A615F: get_gfc_unit (unit.c:353)
==22685==    by 0x509DC93: _gfortran_st_open (open.c:889)
==22685==    by 0x400E4A: MAIN__ (async_io_1.f90:16)
==22685==    by 0x401AA9: main (async_io_1.f90:48)

(plus a few more).  I am currently bootstrapping without the patch
above so I can be sure that this is not an artifact.

However, it looks as if the "locked" argument to close_unit_1 gets
passed the wrong value somehow.  Could you maybe look at that?

Regards

	Thomas

      parent reply	other threads:[~2020-02-17 22:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-31 13:57 Janne Blomqvist
2020-01-31 23:19 ` Janne Blomqvist
2020-02-01 16:37 ` Thomas Koenig
2020-02-01 18:38   ` Janne Blomqvist
2020-02-17 22:33 ` Thomas Koenig [this message]

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=59c43ebb-ba4a-1703-4669-690c5a0c6c8e@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).