From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BED6D3858D20; Thu, 31 Aug 2023 18:52:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BED6D3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693507920; bh=uXo6EfmgDEI2D0ugep+Ejf4AtnTZXoQXgd8WVVmQ2Iw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jQzatDW2YYXZP4gXuYy1SKc9cMezqMxTjviplV+KzsnpZ8V1yR4seKqmb3iFYkjvu +JWht5UxknHPvMOmVm5TEA44i+WxGlyzxa50BfMBFdOqxb55bBlZm+xke8AQlkNiLr /i3DZ8KyDPGmC76+nWaVc2kwizYlLt5O5zz9YCVo= From: "chilikin.k at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/110987] Segmentation fault after finalization of a temporary variable Date: Thu, 31 Aug 2023 18:51:59 +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: 13.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: chilikin.k at gmail dot com X-Bugzilla-Status: UNCONFIRMED 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110987 --- Comment #2 from Kirill Chilikin --- Some additional information: $ gfortran -g -o test test.f90 -fdump-tree-original $ cat test.f90.005t.original | head -n 747 | tail -n 26 { struct t3 zero.25; struct array00_t3 desc.26; struct t3 D.4638; desc.26.dtype =3D {.elem_len=3D80, .rank=3D0, .type=3D5}; desc.26.data =3D (void * restrict) &zero.25; desc.26.span =3D (integer(kind=3D8)) desc.26.dtype.elem_len; { struct array00_t3 desc.27; desc.27.dtype =3D {.elem_len=3D80, .rank=3D0, .type=3D5}; desc.27.data =3D (void * restrict) &x3; desc.27.span =3D (integer(kind=3D8)) desc.27.dtype.elem_len; __final_test_module_T1 (&desc.27, 80, 0); }=20 D.4638 =3D x3; x3 =3D (struct t3) t3_constructor (); if ((struct t1_pointer[0:] * restrict) D.4638.t1.next._data.data !=3D 0= B) { __builtin_free ((void *) D.4638.t1.next._data.data); (struct t1_pointer[0:] * restrict) D.4638.t1.next._data.data =3D 0B; } D.4638.t1.next._vptr =3D (struct __vtype_test_module_T1_pointer * {ref-= all}) &__vtab_test_module_T1_pointer; __vtab_test_module_T3._final (&desc.26, __vtab_test_module_T3._size, 0); } The call of __vtab_test_module_T3._final is on desc.26 pointing to otherwise unused zero.25. $ gdb ./test (gdb) b 102 Breakpoint 1 at 0x4033ca: file test.f90, line 102. (gdb) r Breakpoint 1, test_program () at test.f90:102 102 X3 =3D T3() (gdb) p x2 $1 =3D ( t1 =3D ( n_next =3D 1, next =3D ( _data =3D (( t1 =3D ( _data =3D = 0x4062a0 , _vptr =3D 0x406140 <__test_module_MOD___vtab_test_module_T1> ) )), _vptr =3D 0x4061a0 <__test_module_MOD___vtab_test_module_T1_pointer> ) ), x =3D 1.40129846e-45 ) (gdb) b t1_destructor Breakpoint 2 at 0x4027f0: file test.f90, line 49. (gdb) ignore 2 3 Will ignore next 3 crossings of breakpoint 2. (gdb) c Breakpoint 2, test_module::t1_destructor (self=3D...) at test.f90:49 49 IF (ALLOCATED(SELF%NEXT)) THEN (gdb) backtrace #0 test_module::t1_destructor (self=3D...) at test.f90:49 #1 0x0000000000401813 in test_module::__final_test_module_T1 (array=3D..., byte_stride=3D80, fini_coarray=3D.FALSE.) at test.f90:90 #2 0x00000000004035d0 in test_program () at test.f90:102 (gdb) p self $2 =3D ( n_next =3D 1, next =3D ( _data =3D (( t1 =3D ( _data =3D 0x4062a0 = , _vptr =3D 0x406140 <__test_module_MOD___vtab_test_module_T1> ) )), _vptr =3D 0x4061a0 <__test_module_MOD___vtab_test_module_T1_pointer> ) ) But in the compiled program, it seems to finalize X2%T1.=