This is the mail archive of the gdb-prs@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gdb/3: gdb segfaults associated with FORTRAN (g77) array arguments



>Number:         3
>Category:       gdb
>Synopsis:       gdb segfaults associated with FORTRAN (g77) array arguments
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 01 08:28:01 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Ralph Smith
>Release:        unknown-1.0
>Organization:
>Environment:
GNU/Linux Redhat 6.2
gcc-g77 2.95.2
gdb 5.0 (also gdb 4.18)
>Description:
Symptom: gdb crashes when attempting to print an element
of an array argument to a subprogram, unless index limits
are statically declared.

For subprogram arguments which are arrays with dimensions
not known at compile time, g77 emits stabs specifying an
upper bound index of -1.  If the lower bound is nonnegative,
attempting to print the argument's value crashes gdb.

This bug has been around for a long time, but perhaps not
explained clearly enough to fix.
>How-To-Repeat:
Sample source code:

PROGRAM FOO
INTEGER I,N
PARAMETER (N=2)
INTEGER X(N)
CALL SUBR(X,N)
WRITE(6,*)(X(I),I=1,N)
END

SUBROUTINE SUBR(X,N)
INTEGER I,N
INTEGER X(N)
DO I=1,N
  X(I)=2
ENDDO
RETURN
END

Compilation: g77 -g -o foo foo.f

GDB input causing crash:

b subr_
run
p x
p *x
quit

There is no crash if X is declared X(-1:N-2).
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]