From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5A7FB3851C05; Wed, 13 May 2020 16:24:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5A7FB3851C05 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1589387089; bh=kgD/c5vwrMTYIKj4inBqI/7BvnOieUnloo9N8lDt7OQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PDhXWAS4w64/xFDfQVCs40qPOUMb+29XeE7T1pbAljy4kgn6PgYkgg8U8Xnc8Tz+n FlFbPVwVwcNW3tQtv1knPUWM92ixYVqrigm9Jvti8S85chfrBHSFe0BwiZDvAI5lX4 tlg25EQPgI9gjtqGpbCZ874k+mMgAq0ljLMWenOk= From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/95104] Segfault on a legal WAIT statement Date: Wed, 13 May 2020 16:24:49 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 9.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 May 2020 16:24:49 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95104 --- Comment #4 from kargl at gcc dot gnu.org --- (In reply to Bill Long from comment #3) > A comment from the original user: gfortran 8.3.0 appears to do the right > thing. So perhaps a regression somewhere in the 9.x line? A note of the gfortran wiki says full asynchronous support became available in 9.1. SO, likely a bug introduced in 9. This fixes=20 the segfault as it is never correct to dereference a NULL pointer. Index: libgfortran/io/transfer.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- libgfortran/io/transfer.c (revision 280157) +++ libgfortran/io/transfer.c (working copy) @@ -4492,7 +4492,7 @@ void st_wait_async (st_parameter_wait *wtp) { gfc_unit *u =3D find_unit (wtp->common.unit); - if (ASYNC_IO && u->au) + if (ASYNC_IO && u && u->au) { if (wtp->common.flags & IOPARM_WAIT_HAS_ID) async_wait_id (&(wtp->common), u->au, *wtp->id); With this patch, your program prints '0'. Don't know if this is the only thing that needs fixing. Thanks for the bug report.=