From: Mark Wielaard <mark@klomp.org>
To: Simon Marchi <simark@simark.ca>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] xcoffread.c: Fix -Werror=dangling-pointer= issue with main_subfile.
Date: Mon, 1 May 2023 20:14:01 +0200 [thread overview]
Message-ID: <20230501181401.GH3078@gnu.wildebeest.org> (raw)
In-Reply-To: <fae5cf54-179b-a078-b3c5-a93789cead56@simark.ca>
Hi Simon,
On Mon, May 01, 2023 at 09:53:39AM -0400, Simon Marchi wrote:
> > Fix this by making main_subfile file static that is allocated and
> > deallocated together with inclTable and allocate_include_entry and
> > xcoff_symfile_finish. Adjust the use of main_subfile in
> > process_linenos to take a pointer to the struct subfile.
>
> I'm not familiar at all with this code, but your change looks reasonable
> to me.
I am also not familiar with this code, but noticed that the
fedora-latest and suse-tumbleweed buildbots started failing when they
upgraded to GCC 13.1. The simplest solution seemed to be to give both
structures the same lifetime. I didn't see any regressions with this
fix (but don't actually know if the testsuite triggers this code).
> Some style comments:
>
> > ---
> > gdb/xcoffread.c | 24 +++++++++++++-----------
> > 1 file changed, 13 insertions(+), 11 deletions(-)
> >
> > diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
> > index d71127b40f6..db6f2df6c0a 100644
> > --- a/gdb/xcoffread.c
> > +++ b/gdb/xcoffread.c
> > @@ -498,6 +498,9 @@ static int inclIndx; /* last entry to table */
> > static int inclLength; /* table length */
> > static int inclDepth; /* nested include depth */
> >
> > +/* subfile structure for the main compilation unit. */
> > +static struct subfile *main_subfile;
>
> Remove "struct".
OK.
> > @@ -548,6 +551,7 @@ allocate_include_entry (void)
> > inclTable = XCNEWVEC (InclTable, INITIAL_INCLUDE_TABLE_LENGTH);
> > inclLength = INITIAL_INCLUDE_TABLE_LENGTH;
> > inclIndx = 0;
> > + main_subfile = new (struct subfile);
>
> "new subfile" would be enough.
OK.
> > for (int ii = 0; ii < inclIndx; ++ii)
> > {
> > - if (inclTable[ii].subfile != ((struct subfile *) &main_subfile)
> > + if (inclTable[ii].subfile != ((struct subfile *) main_subfile)
>
> Since you touch this line, I think you could remove the cast.
> main_subfile is already of the right type.
Right.
Will sent v2 with those changes.
Thanks,
Mark
next prev parent reply other threads:[~2023-05-01 18:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-29 21:13 Mark Wielaard
2023-05-01 13:53 ` Simon Marchi
2023-05-01 18:14 ` Mark Wielaard [this message]
2023-05-01 18:19 ` [PATCHv2] " Mark Wielaard
2023-05-02 15:12 ` Tom Tromey
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=20230501181401.GH3078@gnu.wildebeest.org \
--to=mark@klomp.org \
--cc=gdb-patches@sourceware.org \
--cc=simark@simark.ca \
/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).