From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9602 invoked by alias); 17 Jul 2007 15:55:26 -0000 Received: (qmail 9593 invoked by uid 22791); 17 Jul 2007 15:55:26 -0000 X-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,DK_POLICY_SIGNSOME,DNS_FROM_RFC_ABUSE,SPF_PASS X-Spam-Check-By: sourceware.org Received: from e1.ny.us.ibm.com (HELO e1.ny.us.ibm.com) (32.97.182.141) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 17 Jul 2007 15:55:20 +0000 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e1.ny.us.ibm.com (8.13.8/8.13.8) with ESMTP id l6HFtIaD028425 for ; Tue, 17 Jul 2007 11:55:18 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v8.4) with ESMTP id l6HFtIQc529952 for ; Tue, 17 Jul 2007 11:55:18 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id l6HFtHwC023981 for ; Tue, 17 Jul 2007 11:55:17 -0400 Received: from [127.0.0.1] (wecm-9-67-65-20.wecm.ibm.com [9.67.65.20]) by d01av02.pok.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id l6HFtDuH023775; Tue, 17 Jul 2007 11:55:16 -0400 Message-ID: <469CE651.3040403@us.ibm.com> Date: Tue, 17 Jul 2007 18:05:00 -0000 From: Mike Mason User-Agent: Thunderbird 2.0.0.4 (Windows/20070604) MIME-Version: 1.0 To: "Stone, Joshua I" CC: Roland McGrath , systemtap@sourceware.org Subject: Re: kread() and NULL pointers References: <20070716204257.F200B4D05BE@magilla.localdomain> <469BF6BC.1060602@us.ibm.com> <469BFAD5.2010401@intel.com> In-Reply-To: <469BFAD5.2010401@intel.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2007-q3/txt/msg00134.txt.bz2 Stone, Joshua I wrote: > Mike Mason wrote: >> So should the following generate an error? It doesn't. It just >> prints "ptr = 0" and exits. >> >> function test_addr:long () %{ >> void *nullptr = NULL; >> THIS->__retvalue = (long) kread(&(nullptr)); > -----------------------------------------^ > > You're reading the address *of* your pointer, not the address in the > pointer. Thus kread() is dereferencing an address on the stack, and the > value there is NULL. Drop the '&', and change nullptr to a type that's > meaningful to dereference (e.g., long*), and you'll get your error. You're right. I fell into the trap of assuming the kread parameter should always have a '&' in front. Bad assumption on my part. > > The "&(xxx)" pattern you see everywhere is because usually the "xxx" is > a struct value, and so you pass kread() a pointer to that value. Yep, this is what fooled me. Never mind :-) Thanks, Mike > > > Josh