From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by sourceware.org (Postfix) with ESMTPS id 63DFC395C41A for ; Wed, 10 Mar 2021 11:35:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 63DFC395C41A X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [93.241.79.27] ([93.241.79.27]) by web-mail.gmx.net (3c-app-gmx-bs05.server.lan [172.19.170.54]) (via HTTP); Wed, 10 Mar 2021 12:35:19 +0100 MIME-Version: 1.0 Message-ID: From: Martin Stein 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 12:35:19 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:0Ma25OdGqTTpY27eAjaIjyio/TZ5SP494OFOKlRnNNGzM9oZ/Y3NwDxVoDuRxGdA93sll cHtW/BqxuEzz4YO6ZaKfwZsj6O8RdWJUm/zxI4v80Y1RGqn9GvbkD/ZAV8fzZhm7qgRKaPB8kOLF 8o9m73cqUD33IKT9R6aFWouyhkgEhUm+Nkj6WQ68aa73tnEcRruDbFkpkMNFdCfO7K6OeBsScT53 J20Ak1dcBumKTTSBlsdjZ6eDOxmrNu3+M9ADZwK/s1MVunp5XHyhR5iD3ebTXwIo+gg1bY3nyBfu Pc= X-UI-Out-Filterresults: notjunk:1;V03:K0:j7437kP9YhY=:rQpbj1MGz23xx5uK9kKcVw xMFWzmRSUfiUohf0z6H/7+c1wgbKUieUO5yZeVtg6YIJNyfOa3LrJzuijMfOn9czSgVK9cNgC oK6/JHveXnZVw9OqxYp1sOSTPoi4R1iQqnBRa6XPpD1tzD0rp7tQVFKfdtvWYzNeWuvrfB33m Y9NTN1R4lmYxxPFNysoKzt7WZ3NzwmX3uiXq5ozONnItMz00gHGNRn+kvbqx0uf6ItPXC9vaU Diz5wM/GU6yXCg78GkBJNGiGDu71FztYO933lxv+Pv86oh0LF9kPRH2YHQ34MfWYL+Cou0xQF QnNSMrrPjFnilSAdhJ1SR0I8+PSO6BER92cyvNCvQEMH6e7lY/iYJKzn5zdExCP3WNjuCg5yJ l0o3bIonxBzX6HOpG0Sme+ThFvl8sBGHjAesaROdsbQwwhKUKwscUHqBlPSW5EwQr+qbCnE5m hysmhXRmEUYQJ5cOxLRiiy5uhZxZR1Sktdaam7hi+0q4rpIs76vAB8dmOcEn2u0czdElSWQM+ Pij77i4bMDN8kncUt3OoQNlFcxuIf84QtyjKQe+AGok+nLDQwprwi3HnDZgYofP9rhIeFq5Bv hhEZ9pHp236Rg= X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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 11:35:23 -0000 Hi, I am seeing rare but reproducible memory corruptions which I can trace back to lines like write(out,'(a,i8)') 'short string', k where out is a (sufficiently large) character(len=...) variable and k some small integer. The line itself occurs in a subroutine called from within an openmp region. I have seen this in two rather different circumstances. If I change the line to out = 'short string' // toStr(k) and write my own small toStr function, which translates an integer to its string representation, then the memory corruption (usually occuring shortly afterwards but on seemingly unrelated code) disappears. As out is usually not even used (it is a routine for debugging which only uses the output in case something goes wrong), I am pretty sure that the problem is within the write code. Unfortunately I cannot create a small reproducer. As I have already seen data races/memory corruption with write (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88899 and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88768) I am inclined to conclude that the write intrinsic is at fault here. Any idea on how this can be further investigated? If write is indeed at fault, that would be pretty bad. Best regards Martin