From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E69803854835; Tue, 2 Mar 2021 13:25:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E69803854835 From: "pault at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/99307] FAIL: gfortran.dg/class_assign_4.f90 -O0 execution test Date: Tue, 02 Mar 2021 13:25:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pault at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Mar 2021 13:25:05 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99307 --- Comment #5 from Paul Thomas --- (In reply to Tobias Burnus from comment #4) > (In reply to Dominique d'Humieres from comment #1) > > Reduced test >=20 > While -fsanitize=3Daddress,undefined does not find anything on > x86_64-gnu-linux, I do see with valgrind: >=20 > =3D=3D98347=3D=3D Invalid write of size 8 > =3D=3D98347=3D=3D at 0x40397E: test_t1_ (ijd.f90:43) > =3D=3D98347=3D=3D by 0x403A4E: MAIN__ (ijd.f90:60) > =3D=3D98347=3D=3D by 0x403A85: main (ijd.f90:61) > =3D=3D98347=3D=3D Address 0x4f55c98 is 8 bytes inside a block of size 12= alloc'd > =3D=3D98347=3D=3D at 0x483DFAF: realloc (in > /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) > =3D=3D98347=3D=3D by 0x402A6D: test_t1_ (ijd.f90:40) > =3D=3D98347=3D=3D by 0x403A4E: MAIN__ (ijd.f90:60) > =3D=3D98347=3D=3D by 0x403A85: main (ijd.f90:61) >=20 > That's: > x =3D [t2(1,10.0),t2(2,20.0),t2(3,30.0)] > y =3D x > x =3D realloc_t1 (y) ! <<< line 40, 8 bytes alloc'd inside block of siz= e 12 > x =3D realloc_t1 (x) > x =3D x(3:1:-1) + y > x =3D [t2(1,10.0),t2(2,20.0),t2(3,30.0)] ! <<< line 43, invalid write of > size 8 >=20 > Looking at the Fortran code, > x and y have the dynamic type T2 until 'realloc_t1', which turns this i= nto > the dynamic type T1. >=20 > In the last line (line 43), the dynamic type changes again to T2. >=20 > In terms of memory usage: 3*8bytes before the first realloc_t1 call, then > 3*4bytes and for the last line again 3*8bytes. >=20 > * * * >=20 > It seems as if the reallocation does not work properly if the dynamic type > changes =E2=80=93 at least not if the required size increased in the assi= gnment. > (The valgrind message implies that shrinking did work in line 40.) I am unable to see why this is happening. The valgrind complaints go away i= f a different array size is assigned before the changes in type. For some reaso= n, it seems that the vptr->size is not being read correctly or is never set. Paul=