From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 92430 invoked by alias); 16 Jun 2016 16:26:16 -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 92408 invoked by uid 89); 16 Jun 2016 16:26:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=2016-06-09, 20160609, Hx-languages-length:2291, satisfied X-HELO: mailuogwhop.emc.com Received: from mailuogwhop.emc.com (HELO mailuogwhop.emc.com) (168.159.213.141) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 16 Jun 2016 16:26:04 +0000 Received: from maildlpprd02.lss.emc.com (maildlpprd02.lss.emc.com [10.253.24.34]) by mailuogwprd03.lss.emc.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.0) with ESMTP id u5GGQ0Rn011922 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 16 Jun 2016 12:26:01 -0400 X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd03.lss.emc.com u5GGQ0Rn011922 X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd03.lss.emc.com u5GGQ0Rn011922 Received: from mailusrhubprd02.lss.emc.com (mailusrhubprd02.lss.emc.com [10.253.24.20]) by maildlpprd02.lss.emc.com (RSA Interceptor); Thu, 16 Jun 2016 12:25:17 -0400 Received: from MXHUB212.corp.emc.com (MXHUB212.corp.emc.com [10.253.68.82]) by mailusrhubprd02.lss.emc.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.0) with ESMTP id u5GGPicu030037 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=FAIL); Thu, 16 Jun 2016 12:25:44 -0400 Received: from MX203CL03.corp.emc.com ([fe80::4dee:b763:b476:8fbc]) by MXHUB212.corp.emc.com ([10.253.68.82]) with mapi id 14.03.0266.001; Thu, 16 Jun 2016 12:25:43 -0400 From: "taylor, david" To: Joel Brobecker CC: "gdb-patches@sourceware.org" Subject: RE: [PATCH] symtab.c -- Fix off by one allocation bug Date: Thu, 16 Jun 2016 16:26:00 -0000 Message-ID: <63F1AEE13FAE864586D589C671A6E18B062D30@MX203CL03.corp.emc.com> References: <31327.1465840699@usendtaylorx2l> <20160613182324.GB3910@adacore.com> In-Reply-To: <20160613182324.GB3910@adacore.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Sentrion-Hostname: mailusrhubprd02.lss.emc.com X-RSA-Classifications: public X-SW-Source: 2016-06/txt/msg00277.txt.bz2 > From: Joel Brobecker [mailto:brobecker@adacore.com] > Sent: Monday, June 13, 2016 2:23 PM > To: taylor, david > Cc: gdb-patches@sourceware.org > Subject: Re: [PATCH] symtab.c -- Fix off by one allocation bug >=20 > > This fixes a problem found by valgrind. Applying this patch caused no > > regressions on GNU/Linux x86-64 and satisfied valgrind. > > > > * gdb/symtab.c (symbol_set_names): Fix off by one error in > > allocation. >=20 > Thanks for the patch. >=20 > Can you give a little more detail as to why we need that extra byte, and > provide that information in the revision log. This kind of information is= always > very precious when doing archelogy. >=20 > Thanks! Sadly, probably not. This bug was found awhile ago and at the time we were using STAB debugging format. We have since switched to DWARF. I was having problems finding the source of a problem we were having and threw valgrind at it. I ultimately found the other problem via other methods, but valgrind found this problem. I remember staring at the code long enough to convince myself that valgrind was correct. And after increasing it, valgrind was happy. > > --- > > gdb/ChangeLog | 4 ++++ > > gdb/symtab.c | 2 +- > > 2 files changed, 5 insertions(+), 1 deletion(-) > > > > diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9c09269..aaeeb6e > > 100644 > > --- a/gdb/ChangeLog > > +++ b/gdb/ChangeLog > > @@ -1,3 +1,7 @@ > > +2016-06-09 David Taylor > > + > > + * symtab.c (symbol_set_names): Fix off by one error in allocation. > > + > > 2016-06-07 Simon Marchi > > > > * mi/mi-interp.c (mi_record_changed): Add missing braces. > > diff --git a/gdb/symtab.c b/gdb/symtab.c index f7a207a..12e1cf5 100644 > > --- a/gdb/symtab.c > > +++ b/gdb/symtab.c > > @@ -1010,7 +1010,7 @@ symbol_set_names (struct general_symbol_info > *gsymbol, > > =3D ((struct demangled_name_entry *) > > obstack_alloc (&per_bfd->storage_obstack, > > offsetof (struct demangled_name_entry, > demangled) > > - + lookup_len + demangled_len + 2)); > > + + lookup_len + demangled_len + 3)); > > mangled_ptr =3D &((*slot)->demangled[demangled_len + 1]); > > strcpy (mangled_ptr, lookup_name); > > (*slot)->mangled =3D mangled_ptr; > > -- > > 1.9.1 >=20 > -- > Joel