public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/61632] New: memory corruption in Fortran RTL when writing formatted data
@ 2014-06-27 14:33 arnaud02 at users dot sourceforge.net
  2014-06-27 22:36 ` [Bug fortran/61632] " dominiq at lps dot ens.fr
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: arnaud02 at users dot sourceforge.net @ 2014-06-27 14:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61632

            Bug ID: 61632
           Summary: memory corruption in Fortran RTL when writing
                    formatted data
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arnaud02 at users dot sourceforge.net

Problem 1: using the following program:
      program p
      call ss()
      call ss()
      end program p
      subroutine ss
      CHARACTER(3), save :: ZTYP(3)
      DATA ZTYP /'XXX','YYY','ZZZ'/
      write(*,600,IOSTAT=iosa) 0.0,ZTYP
      write(*,*) 'iostat=',iosa
 600  FORMAT(1PE13.5,4X,A3)
      end subroutine ss

with gfortran 4.9.0 results in a executable that crashes:
  0.00000E+00    XXX
 iostat=        5006
  0.00000E+00    XXX

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

A run under valgrind shows:
  0.00000E+00    XXX
 iostat=        5006
  0.00000E+00    XXX
==13768== Invalid read of size 8
==13768==    at 0x414250: _gfortrani_format_error (format.c:1147)
==13768==    by 0x4047D6: require_type.part.7 (transfer.c:1158)
==13768==    by 0x406718: formatted_transfer (transfer.c:1150)
==13768==    by 0x404AE5: _gfortran_transfer_array (transfer.c:2170)

gfortran 4.7.1 is not affected but gfortran 4.8.2 and 4.9.0 are.


Problem 2: using the following program:
      program p
      call ss()
      call ss()
      end program p
      subroutine ss
      CHARACTER(3), save :: ZTYP(3)
      DATA ZTYP /'XXX','YYY','ZZZ'/
      write(*,600) 0.0,ZTYP
 600  FORMAT(1PE13.5,A3)
      end subroutine ss

with gfortran 4.9.0 results in a executable that produces:
--
  0.00000E+00XXX
At line 8 of file io2.f (unit = 6, file = 'stdout')
Fortran runtime error: Expected REAL for item 3 in formatted transfer, got
CHARACTER
(1PE13.5,A3)
   ^
--
The message is unclear as there are only 2 items. Moreover the expected type
looks incorrect. gfortran 4.6.3, 4.7.2, 4.8.2 and 4.9.0 are affected.


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2015-02-12  0:25 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-27 14:33 [Bug fortran/61632] New: memory corruption in Fortran RTL when writing formatted data arnaud02 at users dot sourceforge.net
2014-06-27 22:36 ` [Bug fortran/61632] " dominiq at lps dot ens.fr
2014-06-28 21:20 ` dominiq at lps dot ens.fr
2014-07-12 22:12 ` jvdelisle at gcc dot gnu.org
2014-07-13  7:49 ` dominiq at lps dot ens.fr
2014-07-13 17:05 ` jvdelisle at gcc dot gnu.org
2014-07-13 21:40 ` jvdelisle at gcc dot gnu.org
2014-07-13 22:46 ` dominiq at lps dot ens.fr
2014-07-14  0:47 ` jvdelisle at gcc dot gnu.org
2014-07-14 14:27 ` [Bug fortran/61632] Memory corruption on error " dominiq at lps dot ens.fr
2014-07-14 18:30 ` dominiq at lps dot ens.fr
2014-07-15  2:22 ` jvdelisle at gcc dot gnu.org
2014-07-15  9:08 ` dominiq at lps dot ens.fr
2014-07-15 14:51 ` dominiq at lps dot ens.fr
2014-07-15 14:58 ` sgk at troutmask dot apl.washington.edu
2014-07-15 15:13 ` dominiq at lps dot ens.fr
2014-07-16  3:20 ` jvdelisle at gcc dot gnu.org
2014-07-19  3:24 ` jvdelisle at gcc dot gnu.org
2014-07-20 18:18 ` dominiq at lps dot ens.fr
2014-07-20 20:04 ` jvdelisle at gcc dot gnu.org
2014-07-25 21:51 ` jvdelisle at gcc dot gnu.org
2015-01-15  4:26 ` jvdelisle at gcc dot gnu.org
2015-02-12  0:25 ` jvdelisle at gcc dot gnu.org

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).