public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dfranke at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/32665]  New: allocatable array on lhs deleted while still in use on rhs
Date: Sat, 07 Jul 2007 09:29:00 -0000	[thread overview]
Message-ID: <bug-32665-13648@http.gcc.gnu.org/bugzilla/> (raw)

While experimenting with testcases from PR31320, I hit this:

$> cat alloc.f90
TYPE :: x
  INTEGER, ALLOCATABLE :: a(:)
END TYPE
TYPE(x) :: a

a = x((/ 1, 2, 3 /))
a = x((/ a%a, 4 /))
end

$> gfortran-svn -g -Wall -fdump-tree-original allocatable.f90 && ./a.out
Segmentation fault

$> valgrind --tool=memcheck --leak-check=full ./a.out
[...]
==2287== Invalid read of size 4
==2287==    at 0x804895F: MAIN__ (allocatable.f90:8)
==2287==    by 0x8048C78: main (fmain.c:22)
==2287==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==2287==
==2287== Process terminating with default action of signal 11 (SIGSEGV)
==2287==  Access not within mapped region at address 0x0
==2287==    at 0x804895F: MAIN__ (allocatable.f90:8)
==2287==    by 0x8048C78: main (fmain.c:22)

>From trre-dump:
[...]
     _gfortran_deallocate (a.a.data, &D.1050);
      a.a.data = 0B;
[...]
        D.1029 = (int4[0:] *) a.a.data;
[...]
          while (1)
            {
              if (S.6 > a.a.dim[0].ubound) goto L.1;
              (*(int4[0:] *) atmp.4.data)[offset.5] = (*D.1029)[S.6 * D.1034 +
D.1030];
              offset.5 = offset.5 + 1;
              S.6 = S.6 + 1;
            }
          L.1:;


$> gcc version 4.3.0 20070705 (experimental)


-- 
           Summary: allocatable array on lhs deleted while still in use on
                    rhs
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dfranke at gcc dot gnu dot org


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


             reply	other threads:[~2007-07-07  9:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-07  9:29 dfranke at gcc dot gnu dot org [this message]
2007-07-09 22:42 ` [Bug fortran/32665] " pault at gcc dot gnu dot org
2007-07-13  9:50 ` pault at gcc dot gnu dot org
2007-07-13  9:58 ` dfranke at gcc dot gnu dot org
2007-07-13 13:48 ` pault at gcc dot gnu dot org
2007-07-16  9:45 ` patchapp at dberlin dot org
2007-07-16 12:01 ` pault at gcc dot gnu dot org
2007-07-17 17:23 ` pault at gcc dot gnu dot org
2007-07-17 17:49 ` pault at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-32665-13648@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).