public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/52044] New: [OOP] Invalid memory access with ALLOCATE, default initializer and polymorphic array components
@ 2012-01-29 18:36 burnus at gcc dot gnu.org
  2012-01-29 20:03 ` [Bug fortran/52044] " burnus at gcc dot gnu.org
  2012-02-06 21:24 ` pault at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-29 18:36 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52044
           Summary: [OOP] Invalid memory access with ALLOCATE, default
                    initializer and polymorphic array components
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org


This is a follow up to PR 51972 - or rather it's included test case.

The following program fails at run time with a segfault, cf:

  Conditional jump or move depends on uninitialised value(s)
    at 0x400932: __copy_MAIN___T (nb54af.f90:6)
    by 0x400B96: MAIN__ (nb54af.f90:11)

>From the dump:
  two.a._data.data = (void * restrict) __builtin_malloc (96);
  D.1899 = (struct t[0:] * restrict) two.a._data.data;
  D.1903 = *two.a._vptr->_def_init
  two.a._vptr->_copy (&D.1903,
                      D.1899 + ((S.2 + D.1900) * two.a._vptr->_size));

Thus, there is a MEMSET '\0', CALLOC, or "two.a._data.data = 0" missing as
_copy checks the value of the "dst" argument.

Probably, there is an issue with checking for "component->attr.allocatable"
while on only has "CLASS_DATA (component)->attr.allocatable". I assume that
attr.alloc_comp is correctly set, but the nullification is missed when
iterating over the components. Or there is no nullification with _def_init?


  type t
    integer, allocatable :: x(:)
  end type t

  type t2
    class(t), allocatable :: a(:)
  end type t2

  type(t2) :: two

  allocate (two%a(2)) ! ICE: SEGFAULT
end


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

* [Bug fortran/52044] [OOP] Invalid memory access with ALLOCATE, default initializer and polymorphic array components
  2012-01-29 18:36 [Bug fortran/52044] New: [OOP] Invalid memory access with ALLOCATE, default initializer and polymorphic array components burnus at gcc dot gnu.org
@ 2012-01-29 20:03 ` burnus at gcc dot gnu.org
  2012-02-06 21:24 ` pault at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-29 20:03 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-29 18:49:07 UTC ---
The test case mentioned in comment 0 is test4() of the patch submitted at
http://gcc.gnu.org/ml/fortran/2012-01/msg00252.html


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

* [Bug fortran/52044] [OOP] Invalid memory access with ALLOCATE, default initializer and polymorphic array components
  2012-01-29 18:36 [Bug fortran/52044] New: [OOP] Invalid memory access with ALLOCATE, default initializer and polymorphic array components burnus at gcc dot gnu.org
  2012-01-29 20:03 ` [Bug fortran/52044] " burnus at gcc dot gnu.org
@ 2012-02-06 21:24 ` pault at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pault at gcc dot gnu.org @ 2012-02-06 21:24 UTC (permalink / raw)
  To: gcc-bugs

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

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |pault at gcc dot gnu.org
         Resolution|                            |FIXED

--- Comment #2 from Paul Thomas <pault at gcc dot gnu.org> 2012-02-06 21:24:12 UTC ---
This is now fixed, since __builtin_memset (two.a._data.data, 0, 96); appears
after allocation.

Thanks for this and all the other extracts from Damian and co.'s book!

Cheers

Paul


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

end of thread, other threads:[~2012-02-06 21:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-29 18:36 [Bug fortran/52044] New: [OOP] Invalid memory access with ALLOCATE, default initializer and polymorphic array components burnus at gcc dot gnu.org
2012-01-29 20:03 ` [Bug fortran/52044] " burnus at gcc dot gnu.org
2012-02-06 21:24 ` pault at gcc dot gnu.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).