public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/99307] FAIL: gfortran.dg/class_assign_4.f90   -O0  execution test
Date: Mon, 01 Mar 2021 11:16:04 +0000	[thread overview]
Message-ID: <bug-99307-4-oS0XUBUCCy@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99307-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99307

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

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

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Dominique d'Humieres from comment #1)
> Reduced test

While -fsanitize=address,undefined does not find anything on x86_64-gnu-linux,
I do see with valgrind:

==98347== Invalid write of size 8
==98347==    at 0x40397E: test_t1_ (ijd.f90:43)
==98347==    by 0x403A4E: MAIN__ (ijd.f90:60)
==98347==    by 0x403A85: main (ijd.f90:61)
==98347==  Address 0x4f55c98 is 8 bytes inside a block of size 12 alloc'd
==98347==    at 0x483DFAF: realloc (in
/usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==98347==    by 0x402A6D: test_t1_ (ijd.f90:40)
==98347==    by 0x403A4E: MAIN__ (ijd.f90:60)
==98347==    by 0x403A85: main (ijd.f90:61)

That's:
  x = [t2(1,10.0),t2(2,20.0),t2(3,30.0)]
  y = x
  x = realloc_t1 (y) ! <<< line 40, 8 bytes alloc'd inside block of size 12
  x = realloc_t1 (x)
  x = x(3:1:-1) + y
  x = [t2(1,10.0),t2(2,20.0),t2(3,30.0)] ! <<< line 43, invalid write of size 8

Looking at the Fortran code,
  x and y have the dynamic type T2 until 'realloc_t1', which turns this into
the dynamic type T1.

In the last line (line 43), the dynamic type changes again to T2.

In terms of memory usage: 3*8bytes before the first realloc_t1 call, then
3*4bytes and for the last line again 3*8bytes.

 * * *

It seems as if the reallocation does not work properly if the dynamic type
changes – at least not if the required size increased in the assignment. (The
valgrind message implies that shrinking did work in line 40.)

  parent reply	other threads:[~2021-03-01 11:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-27 23:23 [Bug fortran/99307] New: " danglin at gcc dot gnu.org
2021-02-27 23:28 ` [Bug fortran/99307] " dominiq at lps dot ens.fr
2021-03-01  2:46 ` hp at gcc dot gnu.org
2021-03-01  2:52 ` hp at gcc dot gnu.org
2021-03-01 11:16 ` burnus at gcc dot gnu.org [this message]
2021-03-02 13:25 ` pault at gcc dot gnu.org
2021-03-11 18:08 ` [Bug fortran/99307] FAIL: gfortran.dg/class_assign_4.f90 " pault at gcc dot gnu.org
2021-03-12 10:42 ` dominiq at lps dot ens.fr
2021-04-13 14:08 ` rguenth at gcc dot gnu.org
2021-04-13 14:10 ` rguenth at gcc dot gnu.org
2021-04-13 14:11 ` rguenth at gcc dot gnu.org
2021-04-13 15:57 ` pault at gcc dot gnu.org
2021-04-15  6:34 ` cvs-commit at gcc dot gnu.org
2021-05-04 12:32 ` rguenth at gcc dot gnu.org
2022-04-21 17:05 ` mikael at gcc dot gnu.org
2022-07-05 19:03 ` danglin at gcc dot gnu.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-99307-4-oS0XUBUCCy@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).