This is the mail archive of the gdb@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]
Other format: [Raw text]

Program terminated with SIGSEGV when trying to print an array element


This is a fortran program.  It runs ok without GDB's control.  But it 
terminated with SIGSEGV when running under GDB.  This happened when I
am trying to print an array element in the sub-function.

The testcase is as follows:
============================
        dimension a(10)
        write(*,*)'This is a test.'
        call sub(a,10)
        write(*,*) a
        stop
        end

        subroutine sub(a,n)
        dimension a(n)
        do 100 i=1, 10
          a(i)=i
100     continue
        return
        end
        
The failing GDB session is as follows:
=======================================
# gdb -q ./array
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) b array.f:11
Breakpoint 1 at 0x8048783: file array.f, line 11.
(gdb) r
Starting program: /root/array 
 This is a test.

Breakpoint 1, sub_ (a=0xbf8b9b50, n=@0x804888c) at array.f:11
11                a(i)=i
Current language:  auto; currently fortran
(gdb) p a(1)

Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
The program being debugged stopped while in a function called from GDB.
When the function (at 0xbf8b9b50) is done executing, GDB will silently
stop (instead of continuing to evaluate the expression containing
the function call).


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