From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10442 invoked by alias); 18 Sep 2013 12:30:30 -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 10429 invoked by uid 89); 18 Sep 2013 12:30:30 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Sep 2013 12:30:30 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=3.0 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r8ICU9DM010192 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 18 Sep 2013 08:30:22 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r8ICTxBf022168; Wed, 18 Sep 2013 08:29:59 -0400 Message-ID: <52399CC6.1020807@redhat.com> Date: Wed, 18 Sep 2013 12:30:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Yue Lu CC: Pedro Alves , gdb-patches , Thomas Schwinge , Luis Machado , bug-hurd@gnu.org Subject: Re: [PATCH 1/2] Port gdbserver to GNU/Hurd References: <87txi2i6t6.fsf@kepler.schwinge.homeip.net> <5225C3C6.8090101@redhat.com> <5228DBA7.9050408@redhat.com> <522A2497.7090405@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-09/txt/msg00581.txt.bz2 On 09/12/2013 04:05 AM, Yue Lu wrote: > Honestly to say, I have copied them from function gnu_xfer_memory. But > I think, before reference a pointer, check whether it was a NULL seems > not a bad way :-). We don't go around checking for NULL before _every_ pointer dereference. :-) NULL pointer checks are used when the function's semantics give special meaning to NULL, like for example, for optional parameters. If that's not the function's semantics, and you still may see a NULL pointer, then that tells there's actually a bug that triggered already elsewhere before the function in question was called. IOW, a NULL check in these cases is just masking out a bug in some caller. In some cases, we might add a gdb_assert to catch the bug in a nicer way instead of just crashing. I suspect that what may happen is that at some point it was possible for GDB to select a no-longer-existing-thread (though I can't see how in the current code), and then setting breakpoints, or other operations that require reading memory would crash. -- Pedro Alves