public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/44155]  New: gfortran segmentation fault using iso_c_binding
@ 2010-05-16  5:13 whalen at cray dot com
  2010-05-16  6:58 ` [Bug fortran/44155] " jv244 at cam dot ac dot uk
  2010-05-16 20:25 ` dfranke at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: whalen at cray dot com @ 2010-05-16  5:13 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 6661 bytes --]

gfortran encounters a segfault when trying to compile a standalone file. The
source file itself appears at the end of this comment. But first, the gfortran
behavior

users/whalen> gfortran -v -save-temps test.f90
Driving: gfortran -v -save-temps test.f90 -lgfortran -lm -shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=gcc/dev/20100515/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../../src/gcc-dev/configure --prefix=gcc/dev/20100515/
--with-gmp=gmp/4.3.2/ --with-mpfr=mpfr/2.4.2/ --with-mpc=mpc/0.8.1/
--with-ppl=ppl/0.10.2/ --with-cloog=cloog/0.15.9/
--enable-languages=fortran,c,c++ --enable-lto --with-libelf=libelf/0.8.13
Thread model: posix
gcc version 4.6.0 20100516 (experimental) [trunk revision 159450] (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 gcc/dev/20100515/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/f951
test.f90 -quiet -dumpbase test.f90 -mtune=generic -march=x86-64 -auxbase test
-version -fintrinsic-modules-path
gcc/dev/20100515/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.0/finclude -o
test.s
GNU Fortran (GCC) version 4.6.0 20100516 (experimental) [trunk revision 159450]
(x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.6.0 20100516 (experimental) [trunk revision
159450], GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU Fortran (GCC) version 4.6.0 20100516 (experimental) [trunk revision 159450]
(x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.6.0 20100516 (experimental) [trunk revision
159450], GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
test.f90: In function ‘tetgenf’:
test.f90:125:0: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


users/whalen> cat test.f90
module mod_tetgen

  use iso_c_binding

  implicit none

  type tetgenpolygon
     logical :: initialized = .false.
     integer :: numberofvertices = 0
     integer, pointer :: vertexlist(:)
  end type tetgenpolygon

  type tetgenfacet
     logical :: initialized = .false.
     integer :: numberofpolygons = 0
     type(tetgenpolygon), pointer :: polygonlist(:)
     integer :: numberofholes = 0
     double precision, pointer :: holelist(:,:)
  end type tetgenfacet

  type tetgenio
     logical :: initialized = .false.
     integer :: handle = -1
     integer :: numberofpoints = 0
     double precision, pointer :: pointlist(:,:)
     integer :: numberoffacets = 0
     type(tetgenfacet), pointer :: facetlist(:)
     integer,           pointer :: facetmarkerlist(:)
  end type tetgenio

  interface
     subroutine tetcall &
          (inhandle, outhandle, numberofpoints, pointlist, &
          numberoffacets, numberofpolygons, numberofholes, &
          facetmarkerlist, vertexliststarts, vertexlistvals, &
          numberofoutpoints, outpointlist, numberofoutfacets) &
          bind(c)
       use iso_c_binding
       implicit none
       integer(c_int), value :: inhandle
       integer(c_int), value :: outhandle
       integer(c_int), value :: numberofpoints
       type(c_ptr), value    :: pointlist
       integer(c_int), value :: numberoffacets
       type(c_ptr), value    :: numberofpolygons
       type(c_ptr), value    :: numberofholes
       type(c_ptr), value    :: facetmarkerlist
       type(c_ptr), value    :: vertexliststarts, vertexlistvals
       integer(c_int)        :: numberofoutpoints
       type(c_ptr)           :: outpointlist
       integer(c_int)        :: numberofoutfacets
     end subroutine tetcall
  end interface

contains

  subroutine tetgenf( in, out )

    implicit none

    !-- Transferred variables
    type(tetgenio), target, intent(in)    :: in
    type(tetgenio), target, intent(inout) :: out

    !-- Local variables
    integer ppos, vpos
    integer f, p, v
    type(tetgenfacet),   pointer :: pfacet
    type(tetgenpolygon), pointer :: ppoly
    integer, allocatable, target :: npolylist(:), nholelist(:)
    integer, allocatable, target :: vertexliststarts(:), vertexlistvals(:)
    integer inhandle, outhandle
    type(c_ptr) c_outpointlist

    allocate(npolylist(in%numberoffacets))
    allocate(nholelist(in%numberoffacets))

    ppos = 1
    vpos = 1

    do f = 1, in%numberoffacets
       pfacet => in%facetlist(f)
       do p = 1, pfacet%numberofpolygons
          ppoly => pfacet%polygonlist(p)
          do v = 1, ppoly%numberofvertices
             vpos = vpos + 1
          end do
          ppos = ppos + 1
       end do
    end do

    allocate(vertexliststarts(ppos), vertexlistvals(vpos-1))

    ppos = 1
    vpos = 1

    do f = 1, in%numberoffacets
       pfacet => in%facetlist(f)
       npolylist(f) = pfacet%numberofpolygons
       nholelist(f) = pfacet%numberofholes
       do p = 1, pfacet%numberofpolygons
          vertexliststarts(ppos) = vpos
          ppoly => pfacet%polygonlist(p)
          do v = 1, ppoly%numberofvertices
             vertexlistvals(vpos) = ppoly%vertexlist(v)
             vpos = vpos + 1
          end do
          ppos = ppos + 1
       end do
    end do

    vertexliststarts(ppos) = vpos

    call tetnew(inhandle)
    call tetnew(outhandle)
    call tetcall(inhandle, outhandle,     &
         in%numberofpoints,  &
         c_loc(in%pointlist), &
         in%numberoffacets,  &
         c_loc(npolylist),   &
         c_loc(nholelist),          &
         c_loc(in%facetmarkerlist), &
         c_loc(vertexliststarts), c_loc(vertexlistvals), &
         out%numberofpoints, c_outpointlist, &
         out%numberoffacets)

    call tetfree(inhandle)

    out%initialized = .true.
    out%handle = outhandle
    call c_f_pointer(cptr=c_outpointlist, fptr=out%pointlist, &
         shape=(/ 3, out%numberofpoints /))

    deallocate(vertexliststarts, vertexlistvals)
    deallocate(npolylist, nholelist)

  end subroutine tetgenf


end module mod_tetgen


-- 
           Summary: gfortran segmentation fault using iso_c_binding
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: whalen at cray dot com
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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


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

* [Bug fortran/44155] gfortran segmentation fault using iso_c_binding
  2010-05-16  5:13 [Bug fortran/44155] New: gfortran segmentation fault using iso_c_binding whalen at cray dot com
@ 2010-05-16  6:58 ` jv244 at cam dot ac dot uk
  2010-05-16 20:25 ` dfranke at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: jv244 at cam dot ac dot uk @ 2010-05-16  6:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jv244 at cam dot ac dot uk  2010-05-16 06:57 -------
reduced testcase:

module mod_tetgen
  use iso_c_binding
  type tetgenio
     double precision, pointer :: pointlist(:,:)
     integer :: numberoffacets = 0
  end type tetgenio
contains
  subroutine tetgenf( in, out )
    type(tetgenio), target, intent(in)    :: in
    type(tetgenio), target, intent(inout) :: out
    call tetcall(inhandle, outhandle,     &
         c_loc(in%pointlist), &
         out%numberoffacets)
  end subroutine tetgenf
end module mod_tetgen

#0  0x000000000056f9eb in gfc_conv_procedure_call (se=0x7fff0f31c1a0,
sym=0x13f0400, arg=0x13f3f10, expr=0x13f44b0, append_args=0x0) at
/data03/vondele/gcc_trunk/gcc/gcc/fortran/trans-expr.c:2545
#1  0x00000000005702ba in gfc_conv_function_expr (se=0x7fff0f31c1a0,
expr=0x13f44b0) at /data03/vondele/gcc_trunk/gcc/gcc/fortran/trans-expr.c:3792
#2  0x000000000056a798 in gfc_conv_expr_reference (se=0x13f40f0,
expr=0x13f0400) at /data03/vondele/gcc_trunk/gcc/gcc/fortran/trans-expr.c:4582
#3  0x000000000056ed56 in gfc_conv_procedure_call (se=0x7fff0f31c830,
sym=0x13f38e0, arg=0x13f3850, expr=0x0, append_args=0x0) at
/data03/vondele/gcc_trunk/gcc/gcc/fortran/trans-expr.c:2858
#4  0x000000000058b9f3 in gfc_trans_call (code=0x13f4990, dependency_check=0
'\0', mask=0x0, count1=0x0, invert=0 '\0') at
/data03/vondele/gcc_trunk/gcc/gcc/fortran/trans-stmt.c:378
#5  0x000000000054864f in trans_code (code=0x13f4990, cond=0x0) at
/data03/vondele/gcc_trunk/gcc/gcc/fortran/trans.c:1144
#6  0x00000000005624c7 in gfc_generate_function_code (ns=0x13f2740) at
/data03/vondele/gcc_trunk/gcc/gcc/fortran/trans-decl.c:4456
#7  0x0000000000547c3a in gfc_generate_module_code (ns=0x13e5530) at
/data03/vondele/gcc_trunk/gcc/gcc/fortran/trans.c:1392
#8  0x000000000050d45c in gfc_parse_file () at
/data03/vondele/gcc_trunk/gcc/gcc/fortran/parse.c:4303
#9  0x0000000000544f7d in gfc_be_parse_file (set_yydebug=<value optimized out>)
at /data03/vondele/gcc_trunk/gcc/gcc/fortran/f95-lang.c:239


-- 

jv244 at cam dot ac dot uk changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
      Known to fail|                            |4.4.4 4.5.1 4.6.0
   Last reconfirmed|0000-00-00 00:00:00         |2010-05-16 06:58:00
               date|                            |


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


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

* [Bug fortran/44155] gfortran segmentation fault using iso_c_binding
  2010-05-16  5:13 [Bug fortran/44155] New: gfortran segmentation fault using iso_c_binding whalen at cray dot com
  2010-05-16  6:58 ` [Bug fortran/44155] " jv244 at cam dot ac dot uk
@ 2010-05-16 20:25 ` dfranke at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2010-05-16 20:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from dfranke at gcc dot gnu dot org  2010-05-16 20:24 -------


*** This bug has been marked as a duplicate of 40963 ***


-- 

dfranke at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


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


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

end of thread, other threads:[~2010-05-16 20:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-16  5:13 [Bug fortran/44155] New: gfortran segmentation fault using iso_c_binding whalen at cray dot com
2010-05-16  6:58 ` [Bug fortran/44155] " jv244 at cam dot ac dot uk
2010-05-16 20:25 ` dfranke at gcc dot gnu dot 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).