Bug 2634 - printf incorrectly pushes arguments to %p formats on i686
Summary: printf incorrectly pushes arguments to %p formats on i686
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: runtime (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-02 18:44 UTC by Josh Stone
Modified: 2006-05-03 16:24 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Josh Stone 2006-05-02 18:44:07 UTC
$ stap -e 'probe begin{ printf("%p %d\n",-1,0) exit() }'
ffffffff 4294967295

It is apparant that -1 is being pushed on the stack as a 64-bit value, and then
the printf internals are pulling off only 32-bits for a pointer.  Thus when it
gets to the %d it is at the wrong position on the stack.

The translator needs to cast the -1 down to the pointer size in the call to
_stp_printf / _stp_sprintf.
Comment 1 Frank Ch. Eigler 2006-05-02 18:50:25 UTC
Or rather, the runtime printf() should expect int64_t and narrow internally as
it sees fit.  After all, that's why we have "%p" there - the runtime wants to
decide how big pointers are.

While at it, %p should do the glibc thing and print 0xdeadbeef not just deadbeef.
Comment 2 Martin Hunt 2006-05-02 19:45:12 UTC
Please confirm you are using an up-to-date systemtap. This sounds like an old bug.
Comment 3 Josh Stone 2006-05-03 16:24:31 UTC
Indeed - my CVS tree was out of date.  Revision 1.4 of runtime/vsprintf.c fixed
this.  I'll let Frank reopen this or start a new bug if he wants to press for
prepending '0x'...