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]

_stp_vsnprintf() broken


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 will 'work' on 32-bit architectures
as long as they are little-endian and have the same alignment for
32-bit and 64-bit types.  ARM is 32-bit and (usually) little-endian,
but has differing alignment requirements, so it broke.


Here's a trivial patch against 0505 that should fix it for all platforms:

Index: runtime/vsprintf.c
===================================================================
--- runtime/vsprintf.c	(revision 156)
+++ runtime/vsprintf.c	(working copy)
@@ -319,7 +319,7 @@ int _stp_vsnprintf(char *buf, size_t siz
			}

			str = number(str, end,
-				     (unsigned long) va_arg(args, int64_t),
+				     (unsigned long) va_arg(args, void *),
				     16, field_width, field_width, flags);
			continue;



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