public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "chilikin.k at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-110987-4-zJIgng08pW@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110987-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Kirill Chilikin <chilikin.k at gmail dot com> ---
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 = {.elem_len=80, .rank=0, .type=5};
    desc.26.data = (void * restrict) &zero.25;
    desc.26.span = (integer(kind=8)) desc.26.dtype.elem_len;
    {
      struct array00_t3 desc.27;

      desc.27.dtype = {.elem_len=80, .rank=0, .type=5};
      desc.27.data = (void * restrict) &x3;
      desc.27.span = (integer(kind=8)) desc.27.dtype.elem_len;
      __final_test_module_T1 (&desc.27, 80, 0);
    } 
    D.4638 = x3;
    x3 = (struct t3) t3_constructor ();
    if ((struct t1_pointer[0:] * restrict) D.4638.t1.next._data.data != 0B)
      {
        __builtin_free ((void *) D.4638.t1.next._data.data);
        (struct t1_pointer[0:] * restrict) D.4638.t1.next._data.data = 0B;
      }
    D.4638.t1.next._vptr = (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 = T3()
(gdb) p x2
$1 = ( t1 = ( n_next = 1, next = ( _data = (( t1 = ( _data = 0x4062a0 <x1>,
_vptr = 0x406140 <__test_module_MOD___vtab_test_module_T1> ) )), _vptr =
0x4061a0 <__test_module_MOD___vtab_test_module_T1_pointer> ) ), x =
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=...) at test.f90:49
49          IF (ALLOCATED(SELF%NEXT)) THEN
(gdb) backtrace
#0  test_module::t1_destructor (self=...) at test.f90:49
#1  0x0000000000401813 in test_module::__final_test_module_T1 (array=...,
    byte_stride=80, fini_coarray=.FALSE.) at test.f90:90
#2  0x00000000004035d0 in test_program () at test.f90:102
(gdb) p self
$2 = ( n_next = 1, next = ( _data = (( t1 = ( _data = 0x4062a0 <x1>, _vptr =
0x406140 <__test_module_MOD___vtab_test_module_T1> ) )), _vptr = 0x4061a0
<__test_module_MOD___vtab_test_module_T1_pointer> ) )

But in the compiled program, it seems to finalize X2%T1.

  parent reply	other threads:[~2023-08-31 18:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-11  9:11 [Bug fortran/110987] New: " chilikin.k at gmail dot com
2023-08-11  9:12 ` [Bug fortran/110987] " chilikin.k at gmail dot com
2023-08-31 18:51 ` chilikin.k at gmail dot com [this message]
2023-12-09 13:27 ` chilikin.k at gmail dot com
2024-02-04 20:51 ` anlauf at gcc dot gnu.org
2024-02-05 15:37 ` jhaiduce at gmail dot com
2024-02-05 15:54 ` jhaiduce at gmail dot com
2024-02-05 17:27 ` [Bug fortran/110987] [13/14 Regression] " anlauf at gcc dot gnu.org
2024-02-05 17:34 ` anlauf at gcc dot gnu.org
2024-03-22 13:40 ` law at gcc dot gnu.org
2024-03-28 15:59 ` pault at gcc dot gnu.org
2024-03-29  7:23 ` cvs-commit at gcc dot gnu.org
2024-04-23  9:47 ` [Bug fortran/110987] [13 " pault at gcc dot gnu.org
2024-05-06  9:47 ` cvs-commit at gcc dot gnu.org
2024-05-06  9:50 ` pault 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-110987-4-zJIgng08pW@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).