From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30676 invoked by alias); 10 Nov 2008 19:40:51 -0000 Received: (qmail 30640 invoked by uid 22791); 10 Nov 2008 19:40:51 -0000 X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 10 Nov 2008 19:40:14 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id mAAJe9Nb007921 for ; Mon, 10 Nov 2008 14:40:09 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id mAAJe78E019495; Mon, 10 Nov 2008 14:40:08 -0500 Received: from opsy.redhat.com (vpn-13-202.rdu.redhat.com [10.11.13.202]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id mAAJe7jj024024; Mon, 10 Nov 2008 14:40:07 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id 47EBF3786D6; Mon, 10 Nov 2008 12:40:01 -0700 (MST) To: gdb-patches@sourceware.org Subject: RFA: fix crash-causing bug in copy_type_recursive From: Tom Tromey Reply-To: Tom Tromey X-Attribution: Tom Date: Mon, 10 Nov 2008 20:08:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 X-SW-Source: 2008-11/txt/msg00188.txt.bz2 On the Python branch I ran into a crash that was caused by copy_type_recursive not clearing the memory for new fields. This was probably introduced when I changed all the type flags back in August, but I didn't research to see for sure. The fix is to clear the newly allocated memory. Every other places that allocates new fields does this. I do not have a test failing case for trunk. Built and regtested on x86-64 (compile farm). Ok? (I almost checked this in as obvious...) Tom 2008-11-10 Tom Tromey * gdbtypes.c (copy_type_recursive): Clear new fields. diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index b5a5de0..5b9d0e8 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -2977,6 +2977,7 @@ copy_type_recursive (struct objfile *objfile, nfields = TYPE_NFIELDS (type); TYPE_FIELDS (new_type) = xmalloc (sizeof (struct field) * nfields); + memset (TYPE_FIELDS (new_type), 0, sizeof (struct field) * nfields); for (i = 0; i < nfields; i++) { TYPE_FIELD_ARTIFICIAL (new_type, i) =