From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18383 invoked by alias); 7 Apr 2003 13:07:47 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 18366 invoked from network); 7 Apr 2003 13:07:46 -0000 Received: from unknown (HELO crack.them.org) (65.125.64.184) by sources.redhat.com with SMTP; 7 Apr 2003 13:07:46 -0000 Received: from nevyn.them.org ([66.93.61.169] ident=mail) by crack.them.org with asmtp (Exim 3.12 #1 (Debian)) id 192WLa-0005Id-00; Mon, 07 Apr 2003 08:07:38 -0500 Received: from drow by nevyn.them.org with local (Exim 3.36 #1 (Debian)) id 192WLT-00017q-00; Mon, 07 Apr 2003 09:07:31 -0400 Date: Mon, 07 Apr 2003 13:07:00 -0000 From: Daniel Jacobowitz To: "Thomas,Stephen" Cc: Andrew Cagney , "Rennecke,Joern" , gdb@sources.redhat.com, newlib@sources.redhat.com, bug-glibc@gnu.org, "McGoogan,Sean" Subject: Re: memset (0, 0, 0); Message-ID: <20030407130730.GA4308@nevyn.them.org> Mail-Followup-To: "Thomas,Stephen" , Andrew Cagney , "Rennecke,Joern" , gdb@sources.redhat.com, newlib@sources.redhat.com, bug-glibc@gnu.org, "McGoogan,Sean" References: <9FF3133289A7A84E81E2ED8F5E56B379604384@sh-uk-ex01.uk.w2k.superh.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9FF3133289A7A84E81E2ED8F5E56B379604384@sh-uk-ex01.uk.w2k.superh.com> User-Agent: Mutt/1.5.1i X-SW-Source: 2003-04/txt/msg00060.txt.bz2 On Mon, Apr 07, 2003 at 10:22:04AM +0100, Thomas,Stephen wrote: > Hi, > > gdb appears to call memset(0,0,0) from build_regcache() in gdb/regcache.c. I can't really claim to understand how this works, but this function appears to get called 3 times during gdb initialization: > > static void build_regcache (void) > { > ... > int sizeof_register_valid; > ... > sizeof_register_valid = ((NUM_REGS + NUM_PSEUDO_REGS) * sizeof (*register_valid)); > register_valid = xmalloc (sizeof_register_valid); > memset (register_valid, 0, sizeof_register_valid); > } > > On the 1st time of calling, none of the gdbarch stuff is set up, so NUM_REGS = NUM_PSEUDO_REGS = 0. So xmalloc gets called with size=0. That returns 0 as the 'address', which gets passed to memset. I guess this just works OK on other architectures (it does on x86 anyway). > > Easy enough to fix I suppose, but is that really the point? Yes, I think that really is the point. It's just a bug, IMO. -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer