From patchwork Thu Feb 23 10:35:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 19353 Received: (qmail 109110 invoked by alias); 23 Feb 2017 10:35:55 -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 109082 invoked by uid 89); 23 Feb 2017 10:35:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=695 X-HELO: mail-wm0-f68.google.com Received: from mail-wm0-f68.google.com (HELO mail-wm0-f68.google.com) (74.125.82.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 Feb 2017 10:35:53 +0000 Received: by mail-wm0-f68.google.com with SMTP id m70so1964701wma.1 for ; Thu, 23 Feb 2017 02:35:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=BlAjV1ge2z01txPFC+MDpMFBxHAxwD2LGQXCzI/3DBw=; b=BVALEsLM3Lz1wlw4ZALqKRI9dlUEkAuaP4l1Wg3k832s9wRSRYlpsGb6bwLgygCVlI DjlXqEPY6uXBpl5d6mc88EeuHyBm/EHD6JjSwnhwTR+Z4M6+a4Rk1dpeTSHRgSefxO9C XECY8L3QU4bzL9SRTmpAsnlpPn+O/li1RuIDts1et5YEqPco51BmHBZu8nwkAj8MR6kd d0n+zQu5+BJ3yiwxNUuNctzE3y74vCvTvoboGFyp66Ike0GuCDxTX/5amJwhQLWih9Ca nHEn/Hd3y5B7KGxM57/zcLX30oNeivhbYm8rHZIv0uG8nEJlBDHzXzm2fhswplaaRVqv k8xg== X-Gm-Message-State: AMke39nvF40VbJPOsY3qh2zcp2eq25CGo8kGPuSrs3GzWZ29WUAZ8P2d7+TrVY9d1vaZWQ== X-Received: by 10.28.39.5 with SMTP id n5mr2141565wmn.16.1487846151116; Thu, 23 Feb 2017 02:35:51 -0800 (PST) Received: from E107787-LIN ([194.214.185.158]) by smtp.gmail.com with ESMTPSA id o70sm5771126wmi.26.2017.02.23.02.35.50 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 23 Feb 2017 02:35:50 -0800 (PST) From: Yao Qi To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v2 28/31] Use ui_file_as_string throughout more References: <1476839539-8374-1-git-send-email-palves@redhat.com> <1476968896-13600-1-git-send-email-palves@redhat.com> Date: Thu, 23 Feb 2017 10:35:46 +0000 In-Reply-To: <1476968896-13600-1-git-send-email-palves@redhat.com> (Pedro Alves's message of "Thu, 20 Oct 2016 14:08:16 +0100") Message-ID: <86mvddb3el.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes Pedro Alves writes: > diff --git a/gdb/python/py-varobj.c b/gdb/python/py-varobj.c > index 7e74454..a6b1968 100644 > --- a/gdb/python/py-varobj.c > +++ b/gdb/python/py-varobj.c > @@ -113,11 +113,11 @@ py_varobj_iter_next (struct varobj_iter *self) > error (_("Invalid item from the child list")); > } > > - vitem = XNEW (struct varobj_item); > + vitem = new varobj_item (); > vitem->value = convert_value_from_python (py_v); > if (vitem->value == NULL) > gdbpy_print_stack (); We started to use new but still use xfree somewhere in the code. This patches change xfree to delete. Patch below is obvious. I'll push it in. =================================================================^M ^[[1m^[[31m==20660==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new vs free) on 0x602000090c10^M ^[[1m^[[0m #0 0x2baa77d03631 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x54631)^M #1 0x80e0c8 in xfree(void*) /home/yao/SourceCode/gnu/gdb/git/gdb/common/common-utils.c:100^M #2 0xc13670 in varobj_clear_saved_item /home/yao/SourceCode/gnu/gdb/git/gdb/varobj.c:727^M #3 0xc13957 in update_dynamic_varobj_children /home/yao/SourceCode/gnu/gdb/git/gdb/varobj.c:752^M #4 0xc1841c in varobj_update(varobj**, int) /home/yao/SourceCode/gnu/gdb/git/gdb/varobj.c:1699^M #5 0x5a2bf7 in varobj_update_one /home/yao/SourceCode/gnu/gdb/git/gdb/mi/mi-cmd-var.c:712^M #6 0x5a2a41 in mi_cmd_var_update(char*, char**, int) /home/yao/SourceCode/gnu/gdb/git/gdb/mi/mi-cmd-var.c:695^ ........ ^M ^[[1m^[[32m0x602000090c10 is located 0 bytes inside of 16-byte region [0x602000090c10,0x602000090c20)^M ^[[1m^[[0m^[[1m^[[35mallocated by thread T0 here:^[[1m^[[0m^M #0 0x2baa77d0415f in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5515f)^M #1 0x63613e in py_varobj_iter_next /home/yao/SourceCode/gnu/gdb/git/gdb/python/py-varobj.c:112^M #2 0xc13b89 in update_dynamic_varobj_children /home/yao/SourceCode/gnu/gdb/git/gdb/varobj.c:776^M #3 0xc1841c in varobj_update(varobj**, int) /home/yao/SourceCode/gnu/gdb/git/gdb/varobj.c:1699^M #4 0x5a2bf7 in varobj_update_one /home/yao/SourceCode/gnu/gdb/git/gdb/mi/mi-cmd-var.c:712^M #5 0x5a2a41 in mi_cmd_var_update(char*, char**, int) /home/yao/SourceCode/gnu/gdb/git/gdb/mi/mi-cmd-var.c:695^M gdb: 2017-02-23 Yao Qi * varobj.c (varobj_clear_saved_item): Use delete instead of xfree. (update_dynamic_varobj_children): Likewise. diff --git a/gdb/varobj.c b/gdb/varobj.c index 4b12826..173abf3 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -724,7 +724,7 @@ varobj_clear_saved_item (struct varobj_dynamic *var) if (var->saved_item != NULL) { value_free (var->saved_item->value); - xfree (var->saved_item); + delete var->saved_item; var->saved_item = NULL; } } @@ -799,7 +799,7 @@ update_dynamic_varobj_children (struct varobj *var, can_mention ? cchanged : NULL, i, item); - xfree (item); + delete item; } else {