From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@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:00 -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 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2017-02/txt/msg00616.txt.bz2 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")); > } >=20=20 > - vitem =3D XNEW (struct varobj_item); > + vitem =3D new varobj_item (); > vitem->value =3D convert_value_from_python (py_v); > if (vitem->value =3D=3D 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. --=20 Yao (=E9=BD=90=E5=B0=A7) =46rom 8b4e5d54c9fee2b1d890a9937696297b5cd7ef5c Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Thu, 23 Feb 2017 10:28:44 +0000 Subject: [PATCH] Use delete instead of xfree for varobj_item In commit 2f408ec (Use ui_file_as_string throughout more), we start to new varobj_item, > - vitem =3D XNEW (struct varobj_item); > + vitem =3D new varobj_item (); but we still use xfree. This causes some ASAN errors, -var-update container^M =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D^M ^[[1m^[[31m=3D=3D20660=3D=3DERROR: AddressSanitizer: alloc-dealloc-mismatch= (operator new vs free) on 0x602000090c10^M ^[[1m^[[0m #0 0x2baa77d03631 in __interceptor_free (/usr/lib/x86_64-linu= x-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/gd= b/git/gdb/varobj.c:1699^M #5 0x5a2bf7 in varobj_update_one /home/yao/SourceCode/gnu/gdb/git/gdb/m= i/mi-cmd-var.c:712^M #6 0x5a2a41 in mi_cmd_var_update(char*, char**, int) /home/yao/SourceCo= de/gnu/gdb/git/gdb/mi/mi-cmd-var.c:695^ ........ ^M ^[[1m^[[32m0x602000090c10 is located 0 bytes inside of 16-byte region [0x60= 2000090c10,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/gd= b/git/gdb/varobj.c:1699^M #4 0x5a2bf7 in varobj_update_one /home/yao/SourceCode/gnu/gdb/git/gdb/m= i/mi-cmd-var.c:712^M #5 0x5a2a41 in mi_cmd_var_update(char*, char**, int) /home/yao/SourceCo= de/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 !=3D NULL) { value_free (var->saved_item->value); - xfree (var->saved_item); + delete var->saved_item; var->saved_item =3D NULL; } } @@ -799,7 +799,7 @@ update_dynamic_varobj_children (struct varobj *var, can_mention ? cchanged : NULL, i, item); =20 - xfree (item); + delete item; } else {