From: Guinevere Larsen <guinevere@redhat.com>
To: Simon Marchi <simon.marchi@efficios.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/solib: pass lm_info, original_name and name to solib constructor
Date: Tue, 3 Jun 2025 20:07:55 -0300 [thread overview]
Message-ID: <0bc50478-6756-4825-8080-031e3aef864a@redhat.com> (raw)
In-Reply-To: <20250603153257.55235-1-simon.marchi@efficios.com>
On 6/3/25 12:32 PM, Simon Marchi wrote:
> diff --git a/gdb/solib-target.c b/gdb/solib-target.c
> index 68dc3cc92c0a..dce90a5f8c8e 100644
> --- a/gdb/solib-target.c
> +++ b/gdb/solib-target.c
> @@ -244,14 +244,7 @@ solib_target_current_sos (void)
>
> /* Build a struct solib for each entry on the list. */
> for (lm_info_target_up &info : library_list)
> - {
> - auto &new_solib = sos.emplace_back ();
> -
> - /* We don't need a copy of the name in INFO anymore. */
> - new_solib.name = std::move (info->name);
> - new_solib.original_name = new_solib.name;
> - new_solib.lm_info = std::move (info);
> - }
> + sos.emplace_back (std::move (info), info->name, info->name);
This is a bad idea. I double checked with c++ folk and while no
compilers warn about this, if the compiler evaluates things right to
left (like gcc) this works, but if they evaluate left to right (like
clang), then info->name will be de-referencing null and segfault. This
might also depend on ABI, but the end result is the same: fragile at
best. we'll need something that saves or moves info->name to pass it to
the emplace_back constructor
>
> return sos;
> }
--
Cheers,
Guinevere Larsen
She/Her/Hers
next prev parent reply other threads:[~2025-06-03 23:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-03 15:32 Simon Marchi
2025-06-03 23:07 ` Guinevere Larsen [this message]
2025-06-04 4:38 ` Simon Marchi
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=0bc50478-6756-4825-8080-031e3aef864a@redhat.com \
--to=guinevere@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@efficios.com \
/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