public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Mike Mason <mmlnx@us.ibm.com>
To: "Stone, Joshua I" <joshua.i.stone@intel.com>
Cc: Roland McGrath <roland@redhat.com>, systemtap@sourceware.org
Subject: Re: kread() and NULL pointers
Date: Tue, 17 Jul 2007 18:05:00 -0000	[thread overview]
Message-ID: <469CE651.3040403@us.ibm.com> (raw)
In-Reply-To: <469BFAD5.2010401@intel.com>

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

  reply	other threads:[~2007-07-17 15:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-16 20:43 Mike Mason
2007-07-16 22:53 ` Roland McGrath
2007-07-16 23:10   ` Mike Mason
2007-07-16 23:52     ` Stone, Joshua I
2007-07-17 18:05       ` Mike Mason [this message]
2007-07-17  1:49     ` Roland McGrath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=469CE651.3040403@us.ibm.com \
    --to=mmlnx@us.ibm.com \
    --cc=joshua.i.stone@intel.com \
    --cc=roland@redhat.com \
    --cc=systemtap@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).