From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ruqzBBR/zWOZ5x4AWB0awg (envelope-from ) for ; Sun, 22 Jan 2023 13:23:16 -0500 Received: by simark.ca (Postfix, from userid 112) id 0A5221E128; Sun, 22 Jan 2023 13:23:16 -0500 (EST) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=mnmTaZag; 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=-8.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 A750C1E110 for ; Sun, 22 Jan 2023 13:23:15 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A6C9E3858C39 for ; Sun, 22 Jan 2023 18:23:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A6C9E3858C39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674411794; bh=H1iGEfucKFEt7LqesMe+y8QtsFE9cHyn6ukkrK6ecxs=; h=Date:To:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=mnmTaZagVhX4bZEo58zoRjknhJPWIhVzyBqrmsWTrBYf3TKH4loATprGXI/hMqmES L5Gw+ikMbaVDQJvfv87DxG4LIuDhLJ4VsvPjdqbsKxTwnPKSVv47EArmTok552CJJJ qYRKPwcYBPb1cmGtRrI9G1Bv2h08N6SoDFmCYFu0= Received: from sonic307-54.consmr.mail.ir2.yahoo.com (sonic307-54.consmr.mail.ir2.yahoo.com [87.248.110.31]) by sourceware.org (Postfix) with ESMTPS id 683093858D32 for ; Sun, 22 Jan 2023 18:22:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 683093858D32 X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1674411773; bh=cK5/A0iHZq2AbJ6j7WUZ9PD41xM32dku1l5VLd7k5Xj=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=pf/Mh1aNMkVq/OoFoMJ00+q5BbxikWlfetdntN1mnJGA37dvJ462+w5KwkkV/3zDtU9WJyYQnG7NWG84lGCXNaW0lLuEBVG7CqwfwMnM5hsOaiurNszQqCHGsCLTfn3eNgia8OlAgcIxYiun5gmWJKADC8hHIHHfeWFe9gsbx7/vQpD04FeIKknT6eqbgKjrzo9WPenGiZDiVjbe2FeWIRkxeZfapfmm9msMsw+/1UwwugaUflp2sIVyBW1Ll+xjvUDDlbRYkazISQD4VAiPJXFul7oEX4RzO3sHUKVDrwVvTSb/QpUspOmDYoCfTEI/K6m4Ddnp3A2iYOI1FkBgGQ== X-YMail-OSG: 415jm04VM1lIW7cjmX6MNQe0AkUNiBthE6hrLHTkKH2poKTrtRR13goQ_L_6YyR YBetsIjreAORPayKWO.bNo35RviV1rZTmtkQ8NXoS0L5mjHda3g.WomFKalbxg_092.EnKa3lqGp pbYoOZ_8bhe7RPRwc2iNeY7dFH36IiT1Fk6qX1oFJOxqBVUL3S2xD.96ZmjRDbRuzwz3oM4xNw.U 7pCVvRHAGXdTAsJ0OHjSRpAzQIQhnkOTKCFM0OzdAFdCGOneG6wysHNEuqwPCcKLLYT0FOyKbD1q Zx3U7x_Uz889Rcsg8zrY5wtmyCwUUXspONH0F3ttXtY1UjTyaELd1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l..Q7WW0P GsfMcyM2AL2spY02eWFmnIrZzHP5OEKPjiPX4qxVnMbnhr8FeznQB0ddGJY38hePV0V8IqhmMF2b _KQFoQuCqs7Vt1InCBqCM6zSjeUa5v0TtfuMvgbrltse6_ohByhyZRAWRtoRiuEv.hA810dyu85P S9kTlj_Q8p2Pod0naaYTYMeQlCMgwJh4ANx2OdGlxqm3UNdAZXYUwqrEto8Ez1wu.fOGLx4.HdwV ouZjv4df9ljUZjlEP6xrwtGcTp.YhyrS9_H.STSg4tIZqrWxkqaWdi60nFhrApO3G1ga2yuhU3Ch zra5rmwBpPbsRe7YZPikhLMOQQ23xNG4yOG8yCcBDaiyvJWJlkXzXm5Gu5Sh7P84o86Ny.2ql2Cx BtNMh0zgcyMEZr26Xa6eB8vS.77R.39QLQ4r126LDTeoZo0dsj2i5YFdkR9ooc0q54tBSnv6PIUS IQnXGF.OlpCtyr7roEg3Uwe.1M6X.Tpid5MMB9BisxVPbM7MQTXK7hT63YtvPtuO_4B2T6trjz0_ BTzrprwKj6NPN7imVcf5zcwBVBFfBlh0zulc_6wZ.KMrAjDk7DDw8o2gOW2kc0IvvG_gRWPKYyom odI6DyPJpGBHOYT9uTUdJRLZegjKj_3CHPadJiK3lXVeXZjYmTWUZZozffoA_T.3p90sZ9u8r6o6 6zoy6p2TuS5QrXM4OaS0SK3CLT8LwbMGcAvzfPrT2cRzxP_3.BZovrA6MbrXw_SXBOR_olTBSsQ1 045mnF3Zb7gPIvPzl43GpN8tUj.KlhLzfwR9yDr6v7pxDcTCXqJjQy0tXxf4w27LN8S0QSyw_vyt IMMTIaEpjgLhr X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.ir2.yahoo.com with HTTP; Sun, 22 Jan 2023 18:22:53 +0000 Date: Sun, 22 Jan 2023 18:22:48 +0000 (UTC) To: Hannes Domani via Gdb-patches , Tom Tromey Message-ID: <861084923.719650.1674411768974@mail.yahoo.com> In-Reply-To: <87tu0ijw76.fsf@tromey.com> References: <20230118172740.2171-1-ssbssa.ref@yahoo.de> <20230118172740.2171-1-ssbssa@yahoo.de> <87tu0ijw76.fsf@tromey.com> Subject: Re: [PATCH] Always create a new value object in valpy_do_cast MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Mailer: WebService/1.1.21096 YMailNorrin 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: , From: Hannes Domani via Gdb-patches Reply-To: Hannes Domani Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Am Sonntag, 22. Januar 2023, 18:49:55 MEZ hat Tom Tromey = Folgendes geschrieben: > >>>>> "Hannes" =3D=3D 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>=C2=A0 struct value *val =3D ((value_object *) self)->value; > Hannes>=C2=A0 scoped_value_mark free_values; > Hannes>=C2=A0 res_val =3D value_cast (type, val); // this returns val > Hannes>=C2=A0 result =3D 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: > >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 val_obj->value =3D 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.=C2=A0 = 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. The problem isn't the value that's reference by gdb.Value, instead one of the other values in all_values before it. But release_value removes it from all_values, and it was the exact value that the scoped_value_mark free_values instance was using as the mark point= , and since it was then missing, all_values was cleared completely. And one of those earlier values is still used by the printing later on. > 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.=C2=A0 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. It's also weird for me that users of these APIs need to know this, that's why the way scoped_value_mark works was very surprising for me. Hannes