public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kay Diederichs <kay.diederichs@uni-konstanz.de>
To: fortran@gcc.gnu.org
Subject: Re: Data race within write intrinsic with output into a character variable
Date: Wed, 10 Mar 2021 16:41:58 +0100	[thread overview]
Message-ID: <s2apc6$hak$1@ciao.gmane.io> (raw)
In-Reply-To: <trinity-78886e6d-abdf-4596-a887-43235533dd0b-1615376119642@3c-app-gmx-bs05>

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


  reply	other threads:[~2021-03-10 15:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10 11:35 Martin Stein
2021-03-10 15:41 ` Kay Diederichs [this message]
2021-03-10 20:40 mscfd
2021-03-10 21:38 ` Tobias Burnus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='s2apc6$hak$1@ciao.gmane.io' \
    --to=kay.diederichs@uni-konstanz.de \
    --cc=fortran@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).