cygwin gfortran segfaulting on valid write statements

Brian Inglis
Sat Apr 18 01:01:50 GMT 2020

On 2020-04-17 17:33, Charles Russell wrote:
> On 4/17/2020 2:46 PM, Brian Inglis wrote:
>> Try running under strace:
>>     $ strace -o prog.strace prog -options... args...
>> or gdb:
>>     $ gdb prog
>>     (gdb) run -options... args...
>>     SEGV diagnostics
>>     (gdb) bt
>>     (gdb) q
>> and attach or paste all output.
> The following is the case where I got an error message. Not actually a segfault.
> (Sorry, I'm not a programmer.) The executable, gdb, and strace all produce the
> same output:
> -----------
> At line 889 of file cgcrez.f (unit = 6, file = 'stdout')
> Fortran runtime error: Missing initial left parenthesis in format
> ^

> Here is the indicated line, using list mode in vim to show that there are no
> unexpected nonprinting characters:
>  887           write(6,'(i6,1p3e9.2,x,e9.2,x,0pf6.3,x,1p2e10.2,''@'')')$
>  888      &       iter, reldf,reldb,$
>  889      &       gnorms, x1min, -cosag, beta(1),beta(np)$
>  890 $
> This code compiled and ran on cygwin in the past, and checks out now in debian
> stable.
> In my other case, which I may or may not be able to find again, the program
> failed with no explicit error message like the one above. Stepping through with
> gdb showed that it was also crashing in a valid write statement.

Do you perhaps need an extra pair of parentheses to repeat the formatted output,
perhaps from the second specifier, as you have 5 variable format specifiers and
8 variables?
Showing a bit more context with all variable declarations would help, and you
can use cat -A (== -vET) to show non-printing characters e.g.

$ egrep -nw 'iter|reldf|reldb|gnorms|x1min|cosag|beta|write' cgcrez.f | cat -A

Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.

More information about the Cygwin mailing list