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]

[Bug runtime/21996] New: on 32-bit f26, we're getting dyninst errors when using intptr_t


https://sourceware.org/bugzilla/show_bug.cgi?id=21996

            Bug ID: 21996
           Summary: on 32-bit f26, we're getting dyninst errors when using
                    intptr_t
           Product: systemtap
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: runtime
          Assignee: systemtap at sourceware dot org
          Reporter: dsmith at redhat dot com
  Target Milestone: ---

We're getting dyninst compile errors on 4.12.5-300.fc26.i686+PAE:

====
# stap -p4 -e 'probe process("/bin/ls").begin { print("ls begin") }'
--runtime=dyninst
/usr/local/share/systemtap/runtime/vsprintf.c: In function
‘_stp_vsprint_memory’:
/tmp/stapp2dMC2/stap_9b5821bc23dbd7ecd0e5e5915c67fcbc_904_src.c:3:27: error:
format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 4 has
type ‘int’ [-Werror=format=]
 #define STAP_MSG_LOC2C_01 "read fault [man error::fault] at 0x%lx"
                           ^
/tmp/stapp2dMC2/stap_9b5821bc23dbd7ecd0e5e5915c67fcbc_904_src.c:3:27: note: in
definition of macro ‘STAP_MSG_LOC2C_01’
 #define STAP_MSG_LOC2C_01 "read fault [man error::fault] at 0x%lx"
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/share/systemtap/runtime/dyninst/loc2c-runtime.h:40:6: note: in
expansion of macro ‘DEREF_FAULT’
      DEREF_FAULT(ptr); \
      ^~~~~~~~~~~
/usr/local/share/systemtap/runtime/vsprintf.c:364:16: note: in expansion of
macro ‘uread’
        c_tmp = uread((unsigned char *)(ptr));
                ^~~~~
/tmp/stapp2dMC2/stap_9b5821bc23dbd7ecd0e5e5915c67fcbc_904_src.c:3:27: error:
format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 4 has
type ‘int’ [-Werror=format=]
 #define STAP_MSG_LOC2C_01 "read fault [man error::fault] at 0x%lx"
                           ^
/tmp/stapp2dMC2/stap_9b5821bc23dbd7ecd0e5e5915c67fcbc_904_src.c:3:27: note: in
definition of macro ‘STAP_MSG_LOC2C_01’
 #define STAP_MSG_LOC2C_01 "read fault [man error::fault] at 0x%lx"
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/share/systemtap/runtime/dyninst/loc2c-runtime.h:40:6: note: in
expansion of macro ‘DEREF_FAULT’
      DEREF_FAULT(ptr); \
      ^~~~~~~~~~~
/usr/local/share/systemtap/runtime/dyninst/loc2c-runtime.h:75:15: note: in
expansion of macro ‘uread’
 #define kread uread
               ^~~~~
/usr/local/share/systemtap/runtime/vsprintf.c:366:16: note: in expansion of
macro ‘kread’
        c_tmp = kread((unsigned char *)(ptr));
                ^~~~~
/tmp/stapp2dMC2/stap_9b5821bc23dbd7ecd0e5e5915c67fcbc_904_src.c:3:27: error:
format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 4 has
type ‘int’ [-Werror=format=]
 #define STAP_MSG_LOC2C_01 "read fault [man error::fault] at 0x%lx"
                           ^
/tmp/stapp2dMC2/stap_9b5821bc23dbd7ecd0e5e5915c67fcbc_904_src.c:3:27: note: in
definition of macro ‘STAP_MSG_LOC2C_01’
 #define STAP_MSG_LOC2C_01 "read fault [man error::fault] at 0x%lx"
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/share/systemtap/runtime/dyninst/loc2c-runtime.h:40:6: note: in
expansion of macro ‘DEREF_FAULT’
      DEREF_FAULT(ptr); \
      ^~~~~~~~~~~
/usr/local/share/systemtap/runtime/vsprintf.c:378:13: note: in expansion of
macro ‘uread’
    *str++ = uread((unsigned char *)(ptr));
             ^~~~~
/tmp/stapp2dMC2/stap_9b5821bc23dbd7ecd0e5e5915c67fcbc_904_src.c:3:27: error:
format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 4 has
type ‘int’ [-Werror=format=]
 #define STAP_MSG_LOC2C_01 "read fault [man error::fault] at 0x%lx"
                           ^
/tmp/stapp2dMC2/stap_9b5821bc23dbd7ecd0e5e5915c67fcbc_904_src.c:3:27: note: in
definition of macro ‘STAP_MSG_LOC2C_01’
 #define STAP_MSG_LOC2C_01 "read fault [man error::fault] at 0x%lx"
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/share/systemtap/runtime/dyninst/loc2c-runtime.h:40:6: note: in
expansion of macro ‘DEREF_FAULT’
      DEREF_FAULT(ptr); \
      ^~~~~~~~~~~
/usr/local/share/systemtap/runtime/dyninst/loc2c-runtime.h:75:15: note: in
expansion of macro ‘uread’
 #define kread uread
               ^~~~~
/usr/local/share/systemtap/runtime/vsprintf.c:380:20: note: in expansion of
macro ‘kread’
           *str++ = kread((unsigned char *)(ptr));
                    ^~~~~
cc1: all warnings being treated as errors
WARNING: gcc exited with status: 1
Pass 4: compilation failed.  [man error::pass4]
====

Here's what's going on.

DEREF_FAULT is defined in runtime/loc2c-runtime.h as:

====
#define DEREF_FAULT(addr) ({                                                \
    snprintf(c->error_buffer, sizeof(c->error_buffer),                      \
      STAP_MSG_LOC2C_01, (intptr_t)(addr));   \
    c->last_error = c->error_buffer;                                        \
    goto deref_fault;                                                       \
    })
====

STAP_MSG_LOC2C_01 is defined in translate.cxx as:

====
#define STAP_MSG_LOC2C_01 "read fault [man error::fault] at 0x%lx"
====

So, back in DEREF_FAULT(), the format string expects that 'addr' get cast to a
long (since the format string has '%lx').

On a 32-bit platform, sizeof(int) == sizeof(long) == 4 bytes == 32 bits. An
'intptr_t' is defined as an integer type capable of holding a pointer. So, on a
32-bit platform, that could be an 'int' or a 'long'. On F26 i686,
/usr/include/stdint.h defines it as an 'int'. Defining 'intptr_t' as an int is
fine, since it can hold a pointer (32-bits or 4 bytes). But, that print format
string expects it to be a long, hence the error.

(Note that this didn't happen with the pre-bpf code.)

-- 
You are receiving this mail because:
You are the assignee for the bug.

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