This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FW: Tapset difficulties w/ pointers


Forgot to CC the mailing list...


On Monday, May 01, 2006 12:55 PM, Stone, Joshua I wrote:
> On Sunday, April 30, 2006 11:53 AM, Frank Ch. Eigler wrote:
>> We don't have to return correct answers to trick questions, just
>> avoid hurting the system.  Dereference operations in exposed
>> embedded-C code can be channeled through the same deref() macro used
>> by $target variable expansions, which aims to catch ordinary faults.
> 
> OK, so is this how task_pid() should look?
> 
>   function task_pid:long (task:long) %{ /* pure */
>       struct task_struct *t = (struct task_struct *)(long)THIS->task;
>       THIS->__retvalue = deref(sizeof(t->tgid), &(t->tgid));
>       goto out;
>   deref_fault:
>       CONTEXT->last_error = "pointer dereference fault";
>   %}
> 
> This seems to work, but is it safe from all contexts?
> 
> There seems to be a bug in the deref macros in loc2c-runtime.h -- the
> temporary used to capture the value is an intptr_t, which was
> #defined to long.  A long is 32-bit on i386, so deref(8,addr) will be
> truncated, and probably corrupt the stack with the rest of the value.
> 
>>> One solution is to "hide" task_pid(), perhaps by renaming it to
>>> __task_pid(), and then have the tapset provide variables for pid,
>>> tid, etc. and rely on the compiler to elide those that are unused.
>>> [...]
>> 
>> This style should work well with recent optimizer tweaks.
> 
> If we can make the dereferencing safe, then I would prefer leave it
> exposed.  That way I can have a task_parent function, and let the
> user query info about the parent, grandparent, etc.  
> 
> 
> Josh


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]