I get a segmentation fault while calling LAPACK function DGETRF. The same
program works the way it is supposed to (ie runs without error and gives the
expected output) using either g95 or Sun Studio.

I am running 32-bit Ubuntu 9.04. I've confirmed the error on a Slackware 12.1
box as well, and also in the latest development release (downloaded from the
link on the gfortran wiki).

$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.3-5ubuntu4'
--with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3
--program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug
--enable-objc-gc --enable-mpfr --enable-targets=all --with-tune=generic
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) 


A code sample that will replicate the bug is
program det_test
  implicit none
  integer, parameter :: p15=selected_real_kind(15)
  real(p15) :: A(2,2)
  integer :: info
  A(1,1) = 1.0
  A(1,2) = 0.0
  A(2,1) = 3.0
  A(2,2) = 0.5
  info = 1
  call DGETRF(2,2,A,2,2,info)
  write(*,*) A(1,1)
  write(*,*) A(1,2)
  write(*,*) A(2,1)
  write(*,*) A(2,2)
end program det_test

I saved the file as 'dettest.f95' and compiled using
gfortran -save-temps dettest.f95 -o dettest -L/usr/lib -llapack -lblas

The compiler gave no output. Running the executable, the only output is
"Segmentation Fault".

dettest.s file output:
        .file   "dettest.f95"
        .section        .rodata
        .align 4
        .type   options.0.543, @object
        .size   options.0.543, 28
options.0.543:
        .long   68
        .long   127
        .long   0
        .long   0
        .long   0
        .long   1
        .long   0
        .align 4
.LC4:
        .long   2
.LC5:
        .string "dettest.f95"
        .text
.globl MAIN__
        .type   MAIN__, @function
MAIN__:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $344, %esp
        movl    $options.0.543, 4(%esp)
        movl    $7, (%esp)
        call    _gfortran_set_options
        fld1
        fstpl   -40(%ebp)
        fldz
        fstpl   -24(%ebp)
        fldl    .LC2
        fstpl   -32(%ebp)
        fldl    .LC3
        fstpl   -16(%ebp)
        movl    $1, -4(%ebp)
        leal    -4(%ebp), %eax
        movl    %eax, 20(%esp)
        movl    $.LC4, 16(%esp)
        movl    $.LC4, 12(%esp)
        leal    -40(%ebp), %eax
        movl    %eax, 8(%esp)
        movl    $.LC4, 4(%esp)
        movl    $.LC4, (%esp)
        call    dgetrf_
        movl    $.LC5, -308(%ebp)
        movl    $12, -304(%ebp)
        movl    $128, -316(%ebp)
        movl    $6, -312(%ebp)
        leal    -316(%ebp), %eax
        movl    %eax, (%esp)
        call    _gfortran_st_write
        movl    $8, 8(%esp)
        leal    -40(%ebp), %eax
        movl    %eax, 4(%esp)
        leal    -316(%ebp), %eax
        movl    %eax, (%esp)
        call    _gfortran_transfer_real
        leal    -316(%ebp), %eax
        movl    %eax, (%esp)
        call    _gfortran_st_write_done
        movl    $.LC5, -308(%ebp)
        movl    $13, -304(%ebp)
        movl    $128, -316(%ebp)
        movl    $6, -312(%ebp)
        leal    -316(%ebp), %eax
        movl    %eax, (%esp)
        call    _gfortran_st_write
        movl    $8, 8(%esp)
        leal    -40(%ebp), %eax
        addl    $16, %eax
        movl    %eax, 4(%esp)
        leal    -316(%ebp), %eax
        movl    %eax, (%esp)
        call    _gfortran_transfer_real
        leal    -316(%ebp), %eax
        movl    %eax, (%esp)
        call    _gfortran_st_write_done
        movl    $.LC5, -308(%ebp)
        movl    $14, -304(%ebp)
        movl    $128, -316(%ebp)
        movl    $6, -312(%ebp)
        leal    -316(%ebp), %eax
        movl    %eax, (%esp)
        call    _gfortran_st_write
        movl    $8, 8(%esp)
        leal    -40(%ebp), %eax
        addl    $8, %eax
        movl    %eax, 4(%esp)
        leal    -316(%ebp), %eax
        movl    %eax, (%esp)
        call    _gfortran_transfer_real
        leal    -316(%ebp), %eax
        movl    %eax, (%esp)
        call    _gfortran_st_write_done
        movl    $.LC5, -308(%ebp)
        movl    $15, -304(%ebp)
        movl    $128, -316(%ebp)
        movl    $6, -312(%ebp)
        leal    -316(%ebp), %eax
        movl    %eax, (%esp)
        call    _gfortran_st_write
        movl    $8, 8(%esp)
        leal    -40(%ebp), %eax
        addl    $24, %eax
        movl    %eax, 4(%esp)
        leal    -316(%ebp), %eax
        movl    %eax, (%esp)
        call    _gfortran_transfer_real
        leal    -316(%ebp), %eax
        movl    %eax, (%esp)
        call    _gfortran_st_write_done
        leave
        ret
        .size   MAIN__, .-MAIN__
        .section        .rodata
        .align 8
.LC2:
        .long   0
        .long   1074266112
        .align 8
.LC3:
        .long   0
        .long   1071644672
        .ident  "GCC: (Ubuntu 4.3.3-5ubuntu4) 4.3.3"
        .section        .note.GNU-stack,"",@progbits


-- 
           Summary: Segmentation fault calling DGETRF from gfortran
           Product: gcc
           Version: 4.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lanceb at ksu dot edu


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

Reply via email to