Issue |
83752
|
Summary |
static_assert failed in system installed `libntirpc`
|
Labels |
new issue
|
Assignees |
|
Reporter |
silver-ymz
|
The definition of struct `XDR` is different in `/usr/include/ntirpc/rpc/xdr.h` and `/usr/include/tirpc/rpc/xdr.h`. So the size check can't pass in system installed `libntirpc`.
System Info: `Intel(R) Xeon(R) Gold 6146 CPU @ 3.20GHz`, `Linux iaircag-Precision-7920-Tower 6.2.0-39-generic #40~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 16 10:53:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux`
<details>
<summary>Error Info</summary>
```
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1308:1: error: static_assert failed due to requirement 'sizeof(__sanitizer::__sanitizer_XDR) == sizeof(rpc_xdr)' ""
CHECK_TYPE_SIZE(XDR);
^~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1480:3: note: expanded from macro 'CHECK_TYPE_SIZE'
COMPILER_CHECK(sizeof(__sanitizer_##TYPE) == sizeof(TYPE))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:343:30: note: expanded from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) static_assert(pred, "")
^ ~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1309:1: error: static_assert failed due to requirement '__builtin_offsetof(__sanitizer::__sanitizer_XDR, x_op) == __builtin_offsetof(rpc_xdr, x_op)' ""
CHECK_SIZE_AND_OFFSET(XDR, x_op);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1485:3: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) == \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:343:30: note: expanded from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) static_assert(pred, "")
^ ~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1310:1: error: static_assert failed due to requirement '__builtin_offsetof(__sanitizer::__sanitizer_XDR, x_ops) == __builtin_offsetof(rpc_xdr, x_ops)' ""
CHECK_SIZE_AND_OFFSET(XDR, x_ops);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1485:3: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) == \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:343:30: note: expanded from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) static_assert(pred, "")
^ ~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1311:1: error: static_assert failed due to requirement '__builtin_offsetof(__sanitizer::__sanitizer_XDR, x_public) == __builtin_offsetof(rpc_xdr, x_public)' ""
CHECK_SIZE_AND_OFFSET(XDR, x_public);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1485:3: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) == \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:343:30: note: expanded from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) static_assert(pred, "")
^ ~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1312:1: error: static_assert failed due to requirement '__builtin_offsetof(__sanitizer::__sanitizer_XDR, x_private) == __builtin_offsetof(rpc_xdr, x_private)' ""
CHECK_SIZE_AND_OFFSET(XDR, x_private);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1485:3: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) == \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:343:30: note: expanded from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) static_assert(pred, "")
^ ~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1313:1: error: static_assert failed due to requirement '__builtin_offsetof(__sanitizer::__sanitizer_XDR, x_base) == __builtin_offsetof(rpc_xdr, x_base)' ""
CHECK_SIZE_AND_OFFSET(XDR, x_base);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1485:3: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) == \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:343:30: note: expanded from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) static_assert(pred, "")
^ ~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1314:1: error: static_assert failed due to requirement '__builtin_offsetof(__sanitizer::__sanitizer_XDR, x_handy) == __builtin_offsetof(rpc_xdr, x_handy)' ""
CHECK_SIZE_AND_OFFSET(XDR, x_handy);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1485:3: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) == \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:343:30: note: expanded from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) static_assert(pred, "")
^ ~~~~
7 errors generated.
```
</details>
I try printing the detail size with following code
```cpp
template<size_t A, size_t B> struct TAssertEquality {
static_assert(A==B, "Not equal");
static constexpr bool _cResult = (A==B);
};
static constexpr bool _cIsEqual =
TAssertEquality<sizeof(__sanitizer_XDR), sizeof(XDR)>::_cResult;
```
Results:
```
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1309:3: error: static_assert failed due to requirement '48UL == 112UL' "Not equal"
static_assert(A==B, "Not equal");
^ ~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1313:3: note: in instantiation of template class 'TAssertEquality<48, 112>' requested here
TAssertEquality<sizeof(__sanitizer_XDR), sizeof(XDR)>::_cResult;
^
```
Definition of `XDR` in `libntirpc`:
```
typedef struct rpc_xdr {
const struct xdr_ops {
/* get 4 unsigned bytes from underlying stream */
bool (*x_getunit)(struct rpc_xdr *, uint32_t *);
/* put 4 unsigned bytes to underlying stream */
bool (*x_putunit)(struct rpc_xdr *, const uint32_t);
/* get some bytes from " */
bool (*x_getbytes)(struct rpc_xdr *, char *, u_int);
/* put some bytes to " */
bool (*x_putbytes)(struct rpc_xdr *, const char *, u_int);
/* returns bytes off from beginning */
u_int (*x_getpostn)(struct rpc_xdr *);
/* lets you reposition the stream */
bool (*x_setpostn)(struct rpc_xdr *, u_int);
/* free private resources of this xdr_stream */
void (*x_destroy)(struct rpc_xdr *);
bool (*x_control)(struct rpc_xdr *, int, void *);
/* new vector and refcounted interfaces */
bool (*x_getbufs)(struct rpc_xdr *, xdr_uio *, u_int);
bool (*x_putbufs)(struct rpc_xdr *, xdr_uio *, u_int);
/* Force a new buffer to start (or fail) */
bool (*x_newbuf)(struct rpc_xdr *);
/* Return the count of buffers in the vector from pos */
int (*x_iovcount)(struct rpc_xdr *, u_int, u_int);
/* Fill xdr_vio with buffers from pos */
bool (*x_fillbufs)(struct rpc_xdr *, u_int , xdr_vio *, u_int);
/* Allocate bufs for headers and trailers and insert into vio */
bool (*x_allochdrs)(struct rpc_xdr *, u_int , xdr_vio *, int);
} *x_ops;
void *x_public; /* users' data */
void *x_private; /* pointer to private data */
void *x_lib[2]; /* RPC library private */
uint8_t *x_data; /* private used for position inline */
void *x_base; /* private used for position info */
struct xdr_vio x_v; /* private buffer vector */
u_int x_handy; /* extra private word */
u_int x_flags; /* shared flags */
enum xdr_op x_op; /* operation; fast additional param */
} XDR;
```
Definition of `XDR` in `libtirpc`:
```
typedef struct __rpc_xdr {
enum xdr_op x_op; /* operation; fast additional param */
const struct xdr_ops {
/* get a long from underlying stream */
bool_t (*x_getlong)(struct __rpc_xdr *, long *);
/* put a long to " */
bool_t (*x_putlong)(struct __rpc_xdr *, const long *);
/* get some bytes from " */
bool_t (*x_getbytes)(struct __rpc_xdr *, char *, u_int);
/* put some bytes to " */
bool_t (*x_putbytes)(struct __rpc_xdr *, const char *, u_int);
/* returns bytes off from beginning */
u_int (*x_getpostn)(struct __rpc_xdr *);
/* lets you reposition the stream */
bool_t (*x_setpostn)(struct __rpc_xdr *, u_int);
/* buf quick ptr to buffered data */
int32_t *(*x_inline)(struct __rpc_xdr *, u_int);
/* free privates of this xdr_stream */
void (*x_destroy)(struct __rpc_xdr *);
bool_t (*x_control)(struct __rpc_xdr *, int, void *);
} *x_ops;
char * x_public; /* users' data */
void * x_private; /* pointer to private data */
char * x_base; /* private used for position info */
u_int x_handy; /* extra private word */
} XDR;
```
Definition of `__sanitizer_XDR` in `compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h`
```
struct __sanitizer_XDR {
int x_op;
void *x_ops;
uptr x_public;
uptr x_private;
uptr x_base;
unsigned x_handy;
};
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs