From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by sourceware.org (Postfix) with ESMTPS id 8019C3858025 for ; Wed, 10 Mar 2021 20:40:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8019C3858025 X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [217.224.168.248] ([217.224.168.248]) by web-mail.gmx.net (3c-app-gmx-bap07.server.lan [172.19.172.77]) (via HTTP); Wed, 10 Mar 2021 21:40:26 +0100 MIME-Version: 1.0 Message-ID: From: mscfd To: fortran@gcc.gnu.org Subject: Data race within write intrinsic with output into a character variable Content-Type: text/plain; charset=UTF-8 Date: Wed, 10 Mar 2021 21:40:26 +0100 Importance: normal Sensitivity: Normal Content-Transfer-Encoding: quoted-printable X-Priority: 3 X-Provags-ID: V03:K1:9KGkUxu6+pxmXDRFy8k+HxOQskpF+wFa1OcWyoRL4zUg9NRL3TnlJSuw+DJVPi+079wQb fjdwnel9KbloB2dQQAgNE6WH10G6JsqNDIV05eQIRh2Naecc8QUxWCxvtOxVrn3aQTnpLIsTL1Xe XDUz++io5MZXsntH2UKpo22jG2WYU67OTcAMjHxWRsGXVob+/HoCQ0lCIdYBa/ngv08RcuiXUBTS 6XCqoz0Efb6sGKJZ61ExJp4Mj6aEzHPNykeElZG1UDdHXphw3fvOhZ+H8hsCbVlg/FBYLEpm/MCX /Q= X-UI-Out-Filterresults: notjunk:1;V03:K0:y3q/7X0GNH8=:WP2FTpKkVV3qOrVhHqQ9/1 IpUy/OTmIhpDLLipcSS7Fw22Gu1dlOS3mZeud+EKQ5cJQtqJRdtQX/7tHyiwE/nbT6NybynCH LeLWl+IdSOi5zG/jCX/wxsjMH2tkeHr8K7B3wPiBcBrdHUUtEqn/1yi9sogCxoPWXAEfyXgFB 0qSqRlP4yiQQhLichBiUojHJHLfb3xrCzH0v9ilYzoBNjwx3pdJMzGSTJ49N39z8Tk7veSvyf nKz02ko4/wAyHACPXMNbQTsFRxhirE0c4OPRPIFVbXU4mr5Prl+Fq6Sv0Xp69gYYxlWqvyFTU TNNg6Zo8CocB4D5ruLvQ2VtNlJ4K2JbBW5Z1+sFu2A34vAydxhN3QgKNS+/rqAK7/YLcQiGM1 497vGW7yLY8q2QrfXxG3JzdxfZlmeHP1PNAZW9TAPRCrVT4oimnAzHjDrr7WDmk7SRyq9DxaE RrauyU8rsSftaNL90ulYgDneock/0OvSyPWPmGDmY7iwL11HHbuve1ZVilgGHYMWlYdZE9Vkv iqhJFINdHj1+sqN90XLWlwxY/5ln73zxuyFQ1HYPfrgPJVB6Xo6lkyvvPA3LC5TznA8yaBLfz uLm00ixlTCp+8= X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Mar 2021 20:40:29 -0000 Sorry for the noise, but line breaks and subject were somehow missing=2E=2E=2E > which version of gfortran, and which operating system? I have seen this on two different Linux distros on x86 with a recently compiled version, but also some time ago with an older gfortran 10 version=2E Using helgrind on a simple omp do loop with write to a character variable, I get some possible data races in libgfortran/io/unit=2Ec=2E There global array newunits is allocated and possibly reallocated in "newunit_alloc"=2E According to the lock outputs from helgrind I see that this routine is called even if output is into a character variable=2E Routine "newunit_alloc" uses a lock to avoid having several threads all over the place=2E But newunit_free also writes to newunits array=2E And this routine does not obtain a lock itself (see comment above newunit_free in unit=2Ec) So in theory it can happen that newunit_alloc reallocated newunits, and newunit_free writes to it just at this time=2E As I also use 18 threads the initial size of 16 does not suffice and reallocation does probably indeed happen=2E Also acces to newunit_lwi is not protected as well (and complained about by helgrind)=2E =C2=A0 Could it be that the corresponding write routine in transfer=2Ec which calls newunit_free does not obtain the necessary lock=2E I cannot find it (which does not count for much)=2E =C2=A0 Any thoughts? Martin