public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "janus at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/41478] Corrupted memory using PACK for derived-types with allocated components
Date: Tue, 20 Oct 2009 19:56:00 -0000	[thread overview]
Message-ID: <20091020195622.4346.qmail@sourceware.org> (raw)
In-Reply-To: <bug-41478-15192@http.gcc.gnu.org/bugzilla/>



------- Comment #9 from janus at gcc dot gnu dot org  2009-10-20 19:56 -------
Apart from the double free issue, there might be a more fundamental problem
with PACK and arrays of derived types. For me, Tobias' test case from comment
#8 segfaults already in the call to _gfortran_pack, and so does the following:

type :: container_t
  integer:: entry = -1
end type container_t
type(container_t), dimension(1) :: a1, a2
a2(1)%entry = 1
print *,a1,a2
a1 = pack (a2, mask = [.true.])
print *,a1,a2
end

This does not have any allocatables (so no auto-dealloc happens), but the
output is:

          -1           1
Segmentation fault

which means the second print statement is not reached, i.e. the segfault seems
to happen in _gfortran_pack.

The part of the dump which corresponds to the call to PACK looks like this:

  {
    struct array1_logical(kind=4) parm.4;
    static logical(kind=4) A.3[1] = {1};
    struct array1_container_t parm.2;
    struct array1_container_t parm.1;

    parm.1.dtype = 297;
    parm.1.dim[0].lbound = 1;
    parm.1.dim[0].ubound = 1;
    parm.1.dim[0].stride = 1;
    parm.1.data = (void *) &a1[0];
    parm.1.offset = -1;
    parm.2.dtype = 297;
    parm.2.dim[0].lbound = 1;
    parm.2.dim[0].ubound = 1;
    parm.2.dim[0].stride = 1;
    parm.2.data = (void *) &a2[0];
    parm.2.offset = -1;
    parm.4.dtype = 273;
    parm.4.dim[0].lbound = 1;
    parm.4.dim[0].ubound = 1;
    parm.4.dim[0].stride = 1;
    parm.4.data = (void *) &A.3[0];
    parm.4.offset = 0;
    _gfortran_pack (&parm.1, &parm.2, &parm.4, 0B);
  }

The above test case works when making a1 and a2 simple integers.


-- 


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


  parent reply	other threads:[~2009-10-20 19:56 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-26 20:05 [Bug fortran/41478] New: function "pack" causes double free violation reuter at physik dot uni-freiburg dot de
2009-09-26 20:06 ` [Bug fortran/41478] " reuter at physik dot uni-freiburg dot de
2009-09-26 21:16 ` kargl at gcc dot gnu dot org
2009-09-27  0:39 ` jvdelisle at gcc dot gnu dot org
2009-09-27  9:59 ` dominiq at lps dot ens dot fr
2009-09-27 10:36 ` rguenth at gcc dot gnu dot org
2009-09-27 11:45 ` dominiq at lps dot ens dot fr
2009-09-27 13:12 ` rguenth at gcc dot gnu dot org
2009-10-01 21:22 ` [Bug fortran/41478] Corrupted memory using PACK for derived-types with allocated components burnus at gcc dot gnu dot org
2009-10-20 19:56 ` janus at gcc dot gnu dot org [this message]
2009-10-20 20:06 ` janus at gcc dot gnu dot org
2009-10-20 20:15 ` janus at gcc dot gnu dot org
2009-10-20 20:54 ` janus at gcc dot gnu dot org
2009-10-21  3:04 ` jvdelisle at gcc dot gnu dot org
2009-12-04 20:34 ` tkoenig at gcc dot gnu dot org
2009-12-04 20:37 ` tkoenig at gcc dot gnu dot org
2009-12-04 21:04 ` tkoenig at gcc dot gnu dot org
2009-12-06 22:57 ` janus at gcc dot gnu dot org
2009-12-13 21:51 ` janus at gcc dot gnu dot org
2010-01-11  6:14 ` pault at gcc dot gnu dot org
2010-01-11 12:30 ` dominiq at lps dot ens dot fr
2010-01-11 12:51 ` pault at gcc dot gnu dot org
2010-01-11 13:06 ` burnus at gcc dot gnu dot org
2010-01-11 13:50 ` dominiq at lps dot ens dot fr
2010-01-11 14:04 ` dominiq at lps dot ens dot fr
2010-01-11 17:51 ` dominiq at lps dot ens dot fr
2010-01-11 18:23 ` pault at gcc dot gnu dot org
2010-01-14  6:18 ` pault at gcc dot gnu dot org
2010-01-14  6:20 ` pault at gcc dot gnu dot org
2010-02-07  3:55 ` hjl dot tools at gmail dot com

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=20091020195622.4346.qmail@sourceware.org \
    --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).