User account creation filtered due to spam.

Bug 43532 - Segfault using shape intrinsic function with deferred-shape array
Summary: Segfault using shape intrinsic function with deferred-shape array
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.4.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2010-03-26 11:22 UTC by PierreC
Modified: 2010-10-23 10:05 UTC (History)
2 users (show)

See Also:
Host: x86_64
Target:
Build:
Known to work:
Known to fail: 4.1.2, 4.2.1, 4.3.4, 4.4.4, 4.5.0
Last reconfirmed: 2010-03-27 17:59:38


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description PierreC 2010-03-26 11:22:49 UTC
Reported and confirmed in the fortran mailing list.
test case, trimmed down by Janus:

   implicit none

   type myobj
      real :: myarray(10)
   end type myobj

   real        :: array(10)
   type(myobj) :: obj

   call myfunc(obj,array)

contains

   subroutine myfunc(this, array)
      type(myobj) :: this
      real        :: array(:)
      write (*,*) 'shape bound', shape(this%myarray)
      write (*,*) 'shape input', shape(array)
      write (*,*) shape(array) /= shape(this%myarray) ! SEGFAULT
   end subroutine myfunc

end
Comment 1 Paul Thomas 2010-03-27 17:59:38 UTC
With the function calls interchanged, the problem goes away. ie. with:

write (*,*) shape(this%myarray) /= shape(array) ! SEGFAULT

I can't see from the code yet why this is happening but can confirm the bug.

Paul
Comment 2 Tobias Burnus 2010-03-28 21:19:03 UTC
Valgrind shows:

==4509== Conditional jump or move depends on uninitialised value(s)
==4509==    at 0x4EB51A3: _gfortran_shape_4 (shape_i4.c:47)
==4509==    by 0x40091E: myfunc.1553 (hjfdf.f90:19)
==4509==    by 0x400A87: MAIN__ (hjfdf.f90:10)
==4509==    by 0x400AC2: main (hjfdf.f90:10)
==4509== 
==4509== Use of uninitialised value of size 8
==4509==    at 0x4EB51E2: _gfortran_shape_4 (shape_i4.c:53)
==4509==    by 0x40091E: myfunc.1553 (hjfdf.f90:19)
==4509==    by 0x400A87: MAIN__ (hjfdf.f90:10)
==4509==    by 0x400AC2: main (hjfdf.f90:10)
==4509== 
==4509== Invalid write of size 4
==4509==    at 0x4EB51E2: _gfortran_shape_4 (shape_i4.c:53)
==4509==    by 0x40091E: myfunc.1553 (hjfdf.f90:19)
==4509==    by 0x400A87: MAIN__ (hjfdf.f90:10)
==4509==    by 0x400AC2: main (hjfdf.f90:10)
==4509==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
Comment 3 Thomas Koenig 2010-10-23 10:05:48 UTC
This went away, probably with the commit for PR 46007.

Closing.