public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/60334] New: Segmentation fault on character pointer assignments
@ 2014-02-24 23:35 antony at cosmologist dot info
  2014-02-27  9:54 ` [Bug fortran/60334] " janus at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: antony at cosmologist dot info @ 2014-02-24 23:35 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 60334
           Summary: Segmentation fault on character pointer assignments
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: antony at cosmologist dot info

This compiles OK

    program tester
    implicit none  

    character(LEN=:), pointer :: Y
    character(LEN=0), target :: Empty_String = ''

    Y => test()
    print *, Y

    contains

    function test() result(P)
    character(LEN=:), pointer :: P
    P=> Empty_String  

    end function

    end program


but compiled with  gfortran -Og when run gives

Program received signal 11 (SIGSEGV): Segmentation fault.

Backtrace for this error:
  + [0xb776c400]
  + /lib/i386-linux-gnu/libc.so.6(+0x13afcb) [0xb7529fcb]
  + in the main program
    from file TestClass.f90
  + /lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0xb74084d3]
*** glibc detected *** ./a.out: free(): invalid pointer: 0x09be0898 ***

Other compiler options don't so reliably crash, but still probably invalid code
(I think). It's not specific to the string having zero length.


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

* [Bug fortran/60334] Segmentation fault on character pointer assignments
  2014-02-24 23:35 [Bug fortran/60334] New: Segmentation fault on character pointer assignments antony at cosmologist dot info
@ 2014-02-27  9:54 ` janus at gcc dot gnu.org
  2014-02-27 10:03 ` antony at cosmologist dot info
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu.org @ 2014-02-27  9:54 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

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

--- Comment #1 from janus at gcc dot gnu.org ---
(In reply to Antony Lewis from comment #0) 
> but compiled with  gfortran -Og when run gives
> 
> Program received signal 11 (SIGSEGV): Segmentation fault.

I can confirm the segfault with 4.8, but I don't see it with trunk. However,
also with trunk one gets some valgrind errors:

==13526== Conditional jump or move depends on uninitialised value(s)
==13526==    at 0x4F0E687: _gfortran_transfer_character (in
/usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0)
==13526==    by 0x400806: MAIN__ (c0.f90:8)
==13526==    by 0x400835: main (c0.f90:8)


I don't directly see why the code would be invalid.


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

* [Bug fortran/60334] Segmentation fault on character pointer assignments
  2014-02-24 23:35 [Bug fortran/60334] New: Segmentation fault on character pointer assignments antony at cosmologist dot info
  2014-02-27  9:54 ` [Bug fortran/60334] " janus at gcc dot gnu.org
@ 2014-02-27 10:03 ` antony at cosmologist dot info
  2014-03-22 19:09 ` dominiq at lps dot ens.fr
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: antony at cosmologist dot info @ 2014-02-27 10:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Antony Lewis <antony at cosmologist dot info> ---
I looked for a while for a reproducible crash, which wasn't easy - mostly
behaviour was errratic crashes - I was using 4.9 trunk from a week ago. But
there was definitely a general problem with the code generated by this kind of
construct with various compiler options: a module full of them crashed all over
the place or gave erratic results (compiled with gfortran, it's fine with
ifort). It again worked fine when I changed all the character function results
and temporary variables to allocatables. (my guess was the code is mistakenly
auto-freeing some charater pointers in the same way it does character
allocatables). Happy to provide the more realistic test case if useful to
testing.


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

* [Bug fortran/60334] Segmentation fault on character pointer assignments
  2014-02-24 23:35 [Bug fortran/60334] New: Segmentation fault on character pointer assignments antony at cosmologist dot info
  2014-02-27  9:54 ` [Bug fortran/60334] " janus at gcc dot gnu.org
  2014-02-27 10:03 ` antony at cosmologist dot info
@ 2014-03-22 19:09 ` dominiq at lps dot ens.fr
  2015-01-10 15:00 ` vehre at gmx dot de
  2015-01-23 11:26 ` vehre at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-03-22 19:09 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-03-22
     Ever confirmed|0                           |1

--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed at r208594.


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

* [Bug fortran/60334] Segmentation fault on character pointer assignments
  2014-02-24 23:35 [Bug fortran/60334] New: Segmentation fault on character pointer assignments antony at cosmologist dot info
                   ` (2 preceding siblings ...)
  2014-03-22 19:09 ` dominiq at lps dot ens.fr
@ 2015-01-10 15:00 ` vehre at gmx dot de
  2015-01-23 11:26 ` vehre at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: vehre at gmx dot de @ 2015-01-10 15:00 UTC (permalink / raw)
  To: gcc-bugs

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

Andre Vehreschild <vehre at gmx dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vehre at gmx dot de

--- Comment #4 from Andre Vehreschild <vehre at gmx dot de> ---
Patch available in:
https://gcc.gnu.org/ml/fortran/2015-01/msg00048.html


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

* [Bug fortran/60334] Segmentation fault on character pointer assignments
  2014-02-24 23:35 [Bug fortran/60334] New: Segmentation fault on character pointer assignments antony at cosmologist dot info
                   ` (3 preceding siblings ...)
  2015-01-10 15:00 ` vehre at gmx dot de
@ 2015-01-23 11:26 ` vehre at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: vehre at gcc dot gnu.org @ 2015-01-23 11:26 UTC (permalink / raw)
  To: gcc-bugs

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

vehre at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |vehre at gcc dot gnu.org
         Resolution|---                         |FIXED
           Assignee|unassigned at gcc dot gnu.org      |vehre at gcc dot gnu.org

--- Comment #6 from vehre at gcc dot gnu.org ---
Resolved with commit r219798.


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

end of thread, other threads:[~2015-01-23 11:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-24 23:35 [Bug fortran/60334] New: Segmentation fault on character pointer assignments antony at cosmologist dot info
2014-02-27  9:54 ` [Bug fortran/60334] " janus at gcc dot gnu.org
2014-02-27 10:03 ` antony at cosmologist dot info
2014-03-22 19:09 ` dominiq at lps dot ens.fr
2015-01-10 15:00 ` vehre at gmx dot de
2015-01-23 11:26 ` vehre 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).