public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pault at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/96122] Segfault when using finalizer
Date: Mon, 17 Jan 2022 10:56:22 +0000	[thread overview]
Message-ID: <bug-96122-4-GqxoZmLaqJ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96122-4@http.gcc.gnu.org/bugzilla/>

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

Paul Thomas <pault at gcc dot gnu.org> changed:

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

--- Comment #4 from Paul Thomas <pault at gcc dot gnu.org> ---
(In reply to Thomas Koenig from comment #3)
> (In reply to Andrew Benson from comment #2)
> > (In reply to Dominique d'Humieres from comment #1)
> > > Confirmed. For me it segfaults from GCC7 up to GCC11.
> > 
> > Interesting. This started occurring for me when I updated from GCC10.1 to
> > 11. But, the code I posted is a reduced test case that I created - so maybe
> > the original (non-reduced-test-case) code wasn't triggering this previously
> > for some reason.
> 
> In Gcc 10.1, we did not call the finalizer for all required instances
> (PR 94109).  This has been fixed for gcc11 and the upcoming 10.2 release.
> 
> It is likely that calling a (required?) finalizer again has led to
> the segfault reappearing.
> 
> (Our finalizer handling is a mess, this and PDTs are really the
> only two really buggy fields for F2003 conformance).

The segfault is caused by the following:
                {
                  struct array01_vs parm.6;

                  parm.6.span = 64;
                  parm.6.dtype = {.elem_len=64, .rank=1, .type=5};
                  parm.6.dim[0].lbound = 1;
                  parm.6.dim[0].ubound = 2;
                  parm.6.dim[0].stride = 1;
                  parm.6.data = (void *) &ptr1->n[0];
                  parm.6.offset = -1;
                  __final_a_Vs (&parm.6);
                }

whereas the template for __final_a_Vs is:

integer(kind=4) __final_a_Vs (struct array15_vs & restrict array,
integer(kind=8) byte_stride, logical(kind=1) fini_coarray)

at a minimum, 'byte_stride' is required in the call

I have a mostly complete patch, for finalizers in general, which includes this
and so fixes the segfault.

I hope to submit the current version of the patch today because we have started
stage 4.

Paul

  parent reply	other threads:[~2022-01-17 10:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-08 18:24 [Bug fortran/96122] New: " abensonca at gcc dot gnu.org
2020-07-08 20:09 ` [Bug fortran/96122] " dominiq at lps dot ens.fr
2020-07-08 20:12 ` abensonca at gcc dot gnu.org
2020-07-11 17:36 ` tkoenig at gcc dot gnu.org
2022-01-17 10:56 ` pault at gcc dot gnu.org [this message]
2022-02-01 12:20 ` pault at gcc dot gnu.org
2023-03-18  7:56 ` cvs-commit at gcc dot gnu.org
2023-03-18 17:28 ` 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-96122-4-GqxoZmLaqJ@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).