From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31150 invoked by alias); 14 Jul 2008 17:43:12 -0000 Received: (qmail 31137 invoked by uid 22791); 14 Jul 2008 17:43:12 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 14 Jul 2008 17:42:47 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 311E69813B; Mon, 14 Jul 2008 17:42:46 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id 04FBA9813A; Mon, 14 Jul 2008 17:42:46 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1KIS4T-0002c5-A7; Mon, 14 Jul 2008 13:42:45 -0400 Date: Mon, 14 Jul 2008 17:43:00 -0000 From: Daniel Jacobowitz To: Paul Pluzhnikov Cc: gdb-patches@sourceware.org Subject: Re: [RFA] Patch for PR gdb/2477 Message-ID: <20080714174245.GA9888@caradoc.them.org> Mail-Followup-To: Paul Pluzhnikov , gdb-patches@sourceware.org References: <20080714173149.A03E63A67B4@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080714173149.A03E63A67B4@localhost> User-Agent: Mutt/1.5.17 (2008-05-11) X-IsSubscribed: yes 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-07/txt/msg00287.txt.bz2 On Mon, Jul 14, 2008 at 10:31:49AM -0700, Paul Pluzhnikov wrote: > Greetings, > > Attached patch fixes error in printing NULL pointers when "set print object on". > http://sourceware.org/cgi-bin/gnatsweb.pl?cmd=view&database=gdb&pr=2477 > and adds a test case for it. > > Ok to commit? Thanks for fixing this. The patch isn't OK, but it points to the right solution so we can get it fixed up in no time. The test is OK. > @@ -89,7 +89,8 @@ value_virtual_fn_field (struct value **a > struct type * > value_rtti_type (struct value *v, int *full, int *top, int *using_enc) > { > - if ((current_cp_abi.rtti_type) == NULL) > + if ((current_cp_abi.rtti_type) == NULL > + || VALUE_ADDRESS (v) == 0) > return NULL; > return (*current_cp_abi.rtti_type) (v, full, top, using_enc); > } There's nothing special about zero. It's just an unreadable memory address; the same problem will reappear with any other invalid pointer. So what we need is to catch memory errors. There's no way at present to separate them from other errors, but that's not a big problem. So if we use TRY_CATCH and RETURN_MASK_ERROR around the call to current_cp_abi.rtti_type, we can return NULL in the error case. -- Daniel Jacobowitz CodeSourcery