From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ciao.gmane.io (ciao.gmane.io [116.202.254.214]) by sourceware.org (Postfix) with ESMTPS id DA8BE384B820 for ; Wed, 10 Mar 2021 15:42:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DA8BE384B820 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=uni-konstanz.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gcgf-fortran@m.gmane-mx.org Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1lK0yI-0006PK-QY for fortran@gcc.gnu.org; Wed, 10 Mar 2021 16:42:02 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: fortran@gcc.gnu.org From: Kay Diederichs Subject: Re: Data race within write intrinsic with output into a character variable Date: Wed, 10 Mar 2021 16:41:58 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 In-Reply-To: Content-Language: en-US X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00, FORGED_MUA_MOZILLA, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, NICE_REPLY_A, 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 15:42:06 -0000 On 3/10/21 12:35 PM, Martin Stein via Fortran wrote: > 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 > > which version of gfortran, and which operating system? Kay