diff options
author | Dmitry Antipov <dmantipov@yandex.ru> | 2020-06-04 16:42:30 +0300 |
---|---|---|
committer | Amar Tumballi <amar@kadalu.io> | 2020-06-17 17:26:12 +0000 |
commit | 3db89cf23a5574e902b7785e65655dea65b98aae (patch) | |
tree | 2199a5a9cb629297a35d68af3815877be0e788a8 /configure.ac | |
parent | 9c17cd3b9ca2e44b272b7061de6990dba1ca6937 (diff) |
rpc: fix undefined behaviour in __builtin_ctz
Found with GCC UBsan:
rpcsvc.c:102:36: runtime error: passing zero to ctz(), which is not a valid argument
#0 0x7fcd1ff6faa4 in rpcsvc_get_free_queue_index /path/to/glusterfs/rpc/rpc-lib/src/rpcsvc.c:102
#1 0x7fcd1ff81e12 in rpcsvc_handle_rpc_call /path/to/glusterfs/rpc/rpc-lib/src/rpcsvc.c:837
#2 0x7fcd1ff833ad in rpcsvc_notify /path/to/glusterfs/rpc/rpc-lib/src/rpcsvc.c:1000
#3 0x7fcd1ff8829d in rpc_transport_notify /path/to/glusterfs/rpc/rpc-lib/src/rpc-transport.c:520
#4 0x7fcd0dd72f16 in socket_event_poll_in_async /path/to/glusterfs/rpc/rpc-transport/socket/src/socket.c:2502
#5 0x7fcd0dd8986a in gf_async ../../../../libglusterfs/src/glusterfs/async.h:189
#6 0x7fcd0dd8986a in socket_event_poll_in /path/to/glusterfs/rpc/rpc-transport/socket/src/socket.c:2543
#7 0x7fcd0dd8986a in socket_event_handler /path/to/glusterfs/rpc/rpc-transport/socket/src/socket.c:2934
#8 0x7fcd0dd8986a in socket_event_handler /path/to/glusterfs/rpc/rpc-transport/socket/src/socket.c:2854
#9 0x7fcd2048aff7 in event_dispatch_epoll_handler /path/to/glusterfs/libglusterfs/src/event-epoll.c:640
#10 0x7fcd2048aff7 in event_dispatch_epoll_worker /path/to/glusterfs/libglusterfs/src/event-epoll.c:751
...
Fix, simplify, and prefer 'unsigned long' as underlying bitmap type.
Change-Id: If3f24dfe7bef8bc7a11a679366e219a73caeb9e4
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Fixes: #1283
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 17db0b053f4..d24a7b5cee6 100644 --- a/configure.ac +++ b/configure.ac @@ -911,6 +911,25 @@ if test "x${have_backtrace}" = "xyes"; then fi AC_SUBST(HAVE_BACKTRACE) +dnl Old (before C11) compiler can compile (but not link) this: +dnl +dnl int main () { +dnl _Static_assert(1, "True"); +dnl return 0; +dnl } +dnl +dnl assuming that _Static_assert is an implicitly declared function. So +dnl we're trying to link just to make sure that this is not the case. + +AC_MSG_CHECKING([whether $CC supports C11 _Static_assert]) +AC_TRY_LINK([], [_Static_assert(1, "True");], + [STATIC_ASSERT=yes], [STATIC_ASSERT=no]) + +AC_MSG_RESULT([$STATIC_ASSERT]) +if test x$STATIC_ASSERT = "xyes"; then + AC_DEFINE(HAVE_STATIC_ASSERT, 1, [Define if C11 _Static_assert is supported.]) +fi + if test "x${have_backtrace}" != "xyes"; then AC_TRY_COMPILE([#include <math.h>], [double x=0.0; x=ceil(0.0);], [], |