From patchwork Sun Oct 16 07:05:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 16545 Received: (qmail 31569 invoked by alias); 16 Oct 2016 07:05:52 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 31527 invoked by uid 89); 16 Oct 2016 07:05:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=Hx-languages-length:1315, appended, HX-HELO:sk:gproxy8, H*RU:sk:gproxy8 X-HELO: gproxy8-pub.mail.unifiedlayer.com Received: from gproxy8-pub.mail.unifiedlayer.com (HELO gproxy8-pub.mail.unifiedlayer.com) (67.222.33.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Sun, 16 Oct 2016 07:05:37 +0000 Received: (qmail 3241 invoked by uid 0); 16 Oct 2016 07:05:36 -0000 Received: from unknown (HELO cmgw2) (10.0.90.83) by gproxy8.mail.unifiedlayer.com with SMTP; 16 Oct 2016 07:05:36 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id w75X1t0092f2jeq0175aGn; Sun, 16 Oct 2016 01:05:34 -0600 X-Authority-Analysis: v=2.1 cv=PIacp5aC c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=CH0kA5CcgfcA:10 a=20KFwNOVAAAA:8 a=APAlo_UR1IVcE0Js-18A:9 a=e_O65bzb51kRm2y5VmPK:22 Received: from 174-16-143-211.hlrn.qwest.net ([174.16.143.211]:37434 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_1) (envelope-from ) id 1bvfVk-0003vI-HA; Sun, 16 Oct 2016 01:05:32 -0600 From: Tom Tromey To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 0/3] More cleanup elimination / gdb::unique_ptr References: <1476117992-5689-1-git-send-email-palves@redhat.com> <8a49f675-dc9f-e1e9-73ae-e15522b395ae@redhat.com> Date: Sun, 16 Oct 2016 01:05:28 -0600 In-Reply-To: <8a49f675-dc9f-e1e9-73ae-e15522b395ae@redhat.com> (Pedro Alves's message of "Mon, 10 Oct 2016 17:58:43 +0100") Message-ID: <87funwlqo7.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 X-BWhitelist: no X-Exim-ID: 1bvfVk-0003vI-HA X-Source-Sender: 174-16-143-211.hlrn.qwest.net (bapiya) [174.16.143.211]:37434 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== >>>>> "Pedro" == Pedro Alves writes: Pedro> I'm not sure whether patch #2 is just delayed, or whether it was Pedro> too big for the list (172K on disk). I found a buglet in patch #2. Namely, in rust-lang.c there are some assignments using concat that aren't converted to properly use std::string. This results in a memory leak. In particular look at rust_get_disr_info - I've appended a hunk from a patch of mine (untested), but note mine deletes the do_cleanups, which you don't want to do. Tom diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 5b81283..148e980 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -172,17 +171,15 @@ rust_get_disr_info (struct type *type, const gdb_byte *valaddr, if (value == 0) { ret.field_no = RUST_ENCODED_ENUM_HIDDEN; - ret.name = concat (TYPE_NAME (type), "::", token, (char *) NULL); + ret.name = std::string (TYPE_NAME (type)) + "::" + token; } else { ret.field_no = RUST_ENCODED_ENUM_REAL; - ret.name = concat (TYPE_NAME (type), "::", - rust_last_path_segment (TYPE_NAME (TYPE_FIELD_TYPE (type, 0))), - (char *) NULL); + ret.name = (std::string (TYPE_NAME (type)) + "::" + + rust_last_path_segment (TYPE_NAME (TYPE_FIELD_TYPE (type, 0)))); } - do_cleanups (cleanup); return ret; }