public inbox for
 help / color / mirror / Atom feed
From: Tom Tromey <>
To: Hannes Domani via Gdb-patches <>
Cc: Hannes Domani <>
Subject: Re: [PATCH] Always create a new value object in valpy_do_cast
Date: Sun, 22 Jan 2023 10:49:49 -0700	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <> (Hannes Domani via Gdb-patches's message of "Wed, 18 Jan 2023 18:27:40 +0100")

>>>>> "Hannes" == Hannes Domani via Gdb-patches <> writes:

Hannes> In case a pretty printer casts a value to the same type, so value_cast()
Hannes> returns the same object again, you get this simplified situation:

Hannes> {
Hannes>   struct value *val = ((value_object *) self)->value;
Hannes>   scoped_value_mark free_values;
Hannes>   res_val = value_cast (type, val); // this returns val
Hannes>   result = value_to_value_object (res_val);
Hannes> }

Hannes> So value_to_value_object() removes a value at or before the free_values
Hannes> marker.

Something seems off about this to me.

value_to_value_object does this:

      val_obj->value = release_value (val).release ();

release_value is like an "incref" but its actual semantics are: if the
value is on all_values, remove it and return it; otherwise incref.  That
way the caller always (1) is assured that the value isn't on all_values,
and (2) always gets a new reference.

So, I would expect that call to have released it from all_values and
therefore it would not be destroyed.

Furthermore, no matter what, I'd expect a gdb.Value to hold an owning
reference to the underlying value, so it still shouldn't be destroyed by

I'm not doubting there's a bug here, but I don't understand how it comes
about.  Also, I would rather not fix it the way it is done in this
patch, because I think it is preferable for users of values not to have
to know about whether or not a given API might return the same value.


  reply	other threads:[~2023-01-22 17:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <>
2023-01-18 17:27 ` Hannes Domani
2023-01-22 17:49   ` Tom Tromey [this message]
2023-01-22 18:22     ` Hannes Domani
2023-01-22 20:50       ` Tom Tromey
2023-02-09  2:08         ` Simon Marchi
2023-02-09  3:35           ` Tom Tromey
2023-02-08 23:52   ` Tom Tromey
2023-02-09  6:06     ` Hannes Domani

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* 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).