_stp_vsnprintf() broken
Martin Hunt
hunt@redhat.com
Mon May 14 12:43:00 GMT 2007
On Sat, 2007-05-12 at 12:46 -0500, Quentin Barnes wrote:
> In my ARM port, I noticed "_stp_printf("%p ", pc);" calls were
> outputting trashed pointer values rotated and truncated. I tracked
> the problem down to _stp_vsnprintf(). The case for 'p' was doing
> a va_arg(args, int64_t).
That is actually correct. I implemented %p this way because systemtap
only supports strings, 64-bit ints, and stats. So pointers internally
are always cast to int64_t. We can't simply use %lx to print them
because that would result in things like ffffffffc0400e16 on 32-bit
machines.
So use of %p is correct in tapset functions and systemtap scripts.
Unfortunately it started getting used in runtime C code (notably the
stack functions) to print pointers, which coincidentally works on some
architectures.
So I think the thing to do is clearly document this limitation of %p,
review all %p usage in the runtime and fix as appropriate.
I'll clean this up ASAP. Thanks for reporting the problem.
Martin
More information about the Systemtap
mailing list