Bug 9260 - Segmentation fault with passed-length character arguments
Summary: Segmentation fault with passed-length character arguments
Status: ASSIGNED
Alias: None
Product: gdb
Classification: Unclassified
Component: fortran (show other bugs)
Version: 6.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-11 09:38 UTC by grb
Modified: 2015-04-23 18:55 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
gdbcrash.F (90 bytes, application/octet-stream)
, grb
Details

Note You need to log in before you can comment on or make changes to this bug.
Description grb 2006-08-11 09:38:01 UTC
[Converted from Gnats 2155]

The program 
      PROGRAM  gdbcrash
      call foo('foo')
      END

      SUBROUTINE foo(name)
      CHARACTER*(*)     name
      END

compiled with gfortran 4.0.2
causes gdb 6.5 & 6.3 to segfault like this:

(gdb) break foo_ 
Breakpoint 1 at 0x80484d5: file gdbcrash.F, line 5.
(gdb) run
Starting program: /home/grb/work/foo/gdbcrash 

Breakpoint 1, foo_ (name=@0x8048634, _name=3) at gdbcrash.F:5
Current language:  auto; currently fortran
(gdb) pt name
type = REF TO -> ( char (-1))
(gdb) x/s 0x8048634
0x8048634 <_IO_stdin_used+4>:	 'foo\000'
(gdb) p name

Debugger segmentation fault

With ifort 9.1 (Intel) I got:

(gdb) break foo_ 
Breakpoint 1 at 0x8049462: file gdbcrash.F, line 5.
(gdb) run
Starting program: /home/grb/work/foo/gdbcrash 

Breakpoint 1, 0x08049462 in foo (name=Cannot access memory at address 0x808a168
) at gdbcrash.F:5
warning: Source file is more recent than executable.
Current language:  auto; currently fortran
(gdb) pt name
type = character*136937736
(gdb) p  name
Cannot access memory at address 0x808a168
(gdb) x/s 0x808a168
0x808a168 <STRLITPACK_0>:	 'foo\000'

(gdb) 

likewise if compiled with pgi 6.1 

I works if compiled with g77:
(gdb) break foo_ 
Breakpoint 1 at 0x8048719: file gdbcrash.F, line 7.
(gdb) run
Starting program: /home/grb/work/foo/gdbcrash 

Breakpoint 1, foo_ (name=0x8048924, __g77_length_name=3) at gdbcrash.F:7
Current language:  auto; currently fortran
(gdb) pt name
type = PTR TO -> ( char (1))
(gdb) p name
$1 = (PTR TO -> ( char (1))) 0x8048924
(gdb)

Release:
6.5 & 6.3
Comment 1 Jan Kratochvil 2008-12-23 19:47:06 UTC
FYI the support currently exists in a 3rd party patch:
http://sourceware.org/gdb/wiki/ProjectArcher
http://sourceware.org/gdb/wiki/ArcherBranchManagement
branch archer-jankratochvil-vla

GNU Fortran (GCC) version 4.4.0 20081219 (experimental) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.4.0 20081219 (experimental), GMP version 4.2.2,
MPFR version 2.3.2.
GNU gdb Fedora (6.8-29.fc10)
(gdb) ptype name
type = character*3
(gdb) p name
$1 = 'foo'

The patch is going to be submitted in parts for FSF GDB.