From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2CBE4386184F; Thu, 26 Nov 2020 22:41:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2CBE4386184F From: "tkoenig at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/97589] Segementation fault when allocating coarrays. Date: Thu, 26 Nov 2020 22:41:21 +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: coarray_native X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tkoenig 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: Thu, 26 Nov 2020 22:41:21 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97589 --- Comment #22 from Thomas Koenig --- Hi Toon, it took some time, but we finally figured out that it is actually a bug in your program that is causing problems. It has (shortened) nxglobal =3D 72; This sets the coarray nxglobal to 72 on every image, including image 2. if (this_image() =3D=3D 1) then read(*,config) This optionally reads in nxglobal[1]. ! Why won't this work as nxglobal[:] =3D nx ? do i =3D 2, num_images() nxglobal[i] =3D nxglobal; This sets nxglobal[2] on image 2 from image 1. This is a race condition: It is not clear which store comes first. To fix this, you would need a "sync all" before the if (this_image() =3D 1) statement, or you could set the default value on image 1 only. (Incidentally, looking at this code led to finding a bug in namelist handling, where the implied this_image() was not honored (namelist I/O only worked on image 1), so the time looking at this bug was not wasted :-) By the way, there is also a segfault with GFORTRAN_NUM_IMAGES=3D64, which will need to be investigated.=