http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51591

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jb at gcc dot gnu.org

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-12-17 
09:39:05 UTC ---
(In reply to comment #0)
> > cat testc.c
> int sleepc_ (unsigned int *sec)

This function is actually not used but gfortran's intrinsic "sleep". (The
Fortran program calls "sleep" instead of "sleepc".)

> Sometimes output looks OK:
> But more often there is some garbled text output:
> 0im `m5                               <<<<-----  What's this?

I can reproduce this - though for me the output is more often OK than garbled
(60% vs. 40% of the output of:
  for((I=0;$I < 20; I++)); do ./a.out ; done
)

That's with GCC 4.6. In GCC 4.7, it works much more often (I have to run the
the line above about ~20 times, i.e. approx every 400th run it fails).
Additionally, in 4.7 I do not see garbled output but a segfault.

A backtrace of the core dump shows:

Program terminated with signal 11, Segmentation fault.
#0  _gfortrani_fbuf_flush (u=0x6055d0, mode=<optimized out>)
    at /home/tob/projects/gcc-git/gcc/libgfortran/io/fbuf.c:166
166       if (u->fbuf->act > u->fbuf->pos && u->fbuf->pos > 0)
(gdb) bt
#1  0x00002b37379836bd in _gfortrani_next_record (dtp=0x2b373926dc50, done=1)
    at /home/tob/projects/gcc-git/gcc/libgfortran/io/transfer.c:3397
#2  0x00002b3737983f79 in _gfortran_st_write_done (dtp=0x2b373926dc50)
    at /home/tob/projects/gcc-git/gcc/libgfortran/io/transfer.c:3592

(gdb) p u->fbuf
$3 = (struct fbuf *) 0x7e7e7e7e7e7e7e7e

The value matches:
$ echo $MALLOC_PERTURB_ 
126

Thus, "fbuf" points to malloced memory, which has never been initialized.


> <Nice to see that the STOP 1 results in an exit code of 1, though - new F08
> feature.>

I think gfortran (like several other compilers) does so since years; new (since
4.6) is the support for constant character and integer expressions for (error)
stop.

Reply via email to