Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Matthieu Longo <matthieu.longo@arm.com>
Cc: Tom Tromey <tom@tromey.com>,
	 gdb-patches@sourceware.org,
	 Andrew Burgess <aburgess@redhat.com>
Subject: Re: [PATCH v1] gdb/python: fix memory leak in gdb_py_tp_name
Date: Thu, 28 May 2026 10:43:18 -0600	[thread overview]
Message-ID: <87tsrr5vtl.fsf@tromey.com> (raw)
In-Reply-To: <11b35b46-7e18-471a-94e2-91fef5b287d2@arm.com> (Matthieu Longo's message of "Thu, 28 May 2026 13:46:43 +0100")

>>>>> Matthieu Longo <matthieu.longo@arm.com> writes:

> Sorry, I completely missed those issues while I was changing the code
> in others places.  I should definitely have spotted them if it was not
> my thoughtlessness in those last days.

Don't beat yourself up, it's all just normal stuff.

> -  PyObject *fully_qualified_name = PyType_GetFullyQualifiedName (py_type);
> +  gdbpy_ref<> fully_qualified_name (PyType_GetFullyQualifiedName (py_type));
>    if (fully_qualified_name == nullptr)
> -    return nullptr;
> +    return {};

Something I missed in the initial patch to add gdb_py_tp_name is that if
it fails, then the exception will be set, and the callers don't seem to
be prepared to handle that.

I'm not really sure what to do about it.  I guess the principled thing
would be to change the callers (including those of gdbpy_py_obj_tp_name)
to handle this properly :(

Though if we're really sure that this can only fail pathologically
somehow, I suppose we could add asserts in gdb_py_tp_name itself.

Tom

  reply	other threads:[~2026-05-28 16:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-26 16:04 Matthieu Longo
2026-05-26 16:35 ` Tom Tromey
2026-05-28 12:46   ` Matthieu Longo
2026-05-28 16:43     ` Tom Tromey [this message]
2026-05-28 17:08       ` Matthieu Longo
2026-05-28 19:00         ` Tom Tromey
2026-05-29 10:08           ` Matthieu Longo
2026-05-29 10:52             ` Andrew Burgess
2026-05-29 13:09               ` Tom Tromey
2026-06-01  9:57                 ` Matthieu Longo
2026-06-02  9:36                   ` Andrew Burgess
2026-06-02 14:22                     ` Tom Tromey
2026-06-03 16:30                       ` Matthieu Longo
2026-06-04  9:30                         ` Andrew Burgess
2026-06-05 20:49                         ` Tom Tromey
2026-06-08 10:31                           ` Matthieu Longo
2026-06-08 18:51                             ` Andrew Burgess
2026-06-05 10:06 ` Tom de Vries

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=87tsrr5vtl.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=matthieu.longo@arm.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