From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12706 invoked by alias); 3 Aug 2015 18:14:43 -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 11722 invoked by uid 89); 3 Aug 2015 18:14:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 03 Aug 2015 18:14:41 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 98E2FA100F; Mon, 3 Aug 2015 18:14:40 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t73IEcva012728; Mon, 3 Aug 2015 14:14:39 -0400 Message-ID: <55BFAF8E.8070908@redhat.com> Date: Mon, 03 Aug 2015 18:14:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Doug Evans CC: gdb-patches Subject: Re: [ob/pushed] dwarf2read.c: fix latent buglet References: <1438624857-18851-1-git-send-email-palves@redhat.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-08/txt/msg00044.txt.bz2 On 08/03/2015 07:06 PM, Doug Evans wrote: > On Mon, Aug 3, 2015 at 11:00 AM, Pedro Alves wrote: >> cust->includes is: >> >> struct compunit_symtab >> { >> ... >> struct compunit_symtab **includes; >> >> gdb/ChangeLog: >> 2015-08-03 Pedro Alves >> >> * dwarf2read.c (compute_compunit_symtab_includes): Use size of struct >> compunit_symtab pointer. >> --- >> gdb/dwarf2read.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c >> index 24a4022..b5ffd04 100644 >> --- a/gdb/dwarf2read.c >> +++ b/gdb/dwarf2read.c >> @@ -7983,7 +7983,7 @@ compute_compunit_symtab_includes (struct dwarf2_per_cu_data *per_cu) >> len = VEC_length (compunit_symtab_ptr, result_symtabs); >> cust->includes >> = obstack_alloc (&dwarf2_per_objfile->objfile->objfile_obstack, >> - (len + 1) * sizeof (struct symtab *)); >> + (len + 1) * sizeof (struct compunit_symtab *)); >> for (ix = 0; >> VEC_iterate (compunit_symtab_ptr, result_symtabs, ix, >> compunit_symtab_iter); > > Bleah. > Since sizeof (struct symtab) < sizeof (struct compunit_symtab) (64 vs > 112 for amd64) Yes, but that's not the case here -- this is 'sizeof (foo *)' not 'sizeof (foo)'. So it's actually pretty harmless. Should have called that out explicitly, sorry. This was caught in the C++ conversion, where the "insert-casts" script would generate: cust->includes - = obstack_alloc (&dwarf2_per_objfile->objfile->objfile_obstack, + = (struct symtab **) obstack_alloc (&dwarf2_per_objfile->objfile->objfile_obstack, (len + 1) * sizeof (struct symtab *)); which would then fail to compile. Thanks, Pedro Alves