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