From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id iFHZOk13zWNB5B4AWB0awg (envelope-from ) for ; Sun, 22 Jan 2023 12:50:05 -0500 Received: by simark.ca (Postfix, from userid 112) id E52A41E128; Sun, 22 Jan 2023 12:50:05 -0500 (EST) Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=kx7RnT+t; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 6AAAC1E110 for ; Sun, 22 Jan 2023 12:50:05 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C6FD73858430 for ; Sun, 22 Jan 2023 17:50:04 +0000 (GMT) Received: from progateway7-pub.mail.pro1.eigbox.com (gproxy5-pub.mail.unifiedlayer.com [67.222.38.55]) by sourceware.org (Postfix) with ESMTPS id F004F3858D32 for ; Sun, 22 Jan 2023 17:49:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F004F3858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw11.mail.unifiedlayer.com (unknown [10.0.90.126]) by progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id 63A0C10048EDC for ; Sun, 22 Jan 2023 17:49:52 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id JeTYpZQqoGjYaJeTYp5uAB; Sun, 22 Jan 2023 17:49:52 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=cdgXElPM c=1 sm=1 tr=0 ts=63cd7740 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=CCpqsmhAAAAA:8 a=qHVa-MG42KtIjTxQts4A:9 a=ul9cdbp4aOFLsgKbc677:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References :Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=US9VjJRseW4qAQalhUcS+rDILm1zBfLUcBZcj6GIz2Q=; b=kx7RnT+tQ9ADjXqqB0rwRQi/bN 5IMci5+JKtBkE/XisHjj+ErTd6kvf8/5oNTpZDHXActnlAkAKoLXyWd5Or7CI/gCMYVYFIl1OGl3j kbaEOX2XfML1gOTXlUffO6oso; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:51922 helo=prentzel) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pJeTX-000YZo-Vm; Sun, 22 Jan 2023 10:49:52 -0700 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 References: <20230118172740.2171-1-ssbssa.ref@yahoo.de> <20230118172740.2171-1-ssbssa@yahoo.de> X-Attribution: Tom Date: Sun, 22 Jan 2023 10:49:49 -0700 In-Reply-To: <20230118172740.2171-1-ssbssa@yahoo.de> (Hannes Domani via Gdb-patches's message of "Wed, 18 Jan 2023 18:27:40 +0100") Message-ID: <87tu0ijw76.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.76.186 X-Source-L: No X-Exim-ID: 1pJeTX-000YZo-Vm X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (prentzel) [97.122.76.186]:51922 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" >>>>> "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 value_free_to_mark. 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. Tom