New obstack uses sensible types, size_t instead of int for length params. Since libsanitizer does not use prototypes from obstack.h to call the real functions, it's necessary to update the libsanitizer function declarations emitted by the INTERCEPTOR macro.
As per the comment added to configure.ac, it would be nice if we could update to a more recent autoconf, but what I have should do given the limited target support for libsanitizer. I'll be pushing this one upstream too, when I figure out something reasonable for cmake. * sanitizer_common/sanitizer_common_interceptors.inc: Update size params for _obstack_begin_1, _obstack_begin, _obstack_newchunk interceptors. * configure.ac: Substitute OBSTACK_DEFS. * asan/Makefile.am: Add OBSTACK_DEFS to DEFS. * tsan/Makefile.am: Likewise. * configure: Regenerate. * Makefile.in: Regenerate. * asan/Makefile.in: Regenerate. * interception/Makefile.in: Regenerate. * libbacktrace/Makefile.in: Regenerate. * lsan/Makefile.in: Regenerate. * sanitizer_common/Makefile.in: Regenerate. * tsan/Makefile.in: Regenerate. * ubsan/Makefile.in: Regenerate. diff --git a/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc b/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc index 9b8c77e..92b9027 100644 --- a/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc +++ b/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc @@ -4874,8 +4874,9 @@ static void initialize_obstack(__sanitizer_obstack *obstack) { sizeof(*obstack->chunk)); } -INTERCEPTOR(int, _obstack_begin_1, __sanitizer_obstack *obstack, int sz, - int align, void *(*alloc_fn)(uptr arg, uptr sz), +INTERCEPTOR(int, _obstack_begin_1, __sanitizer_obstack *obstack, + _OBSTACK_SIZE_T sz, _OBSTACK_SIZE_T align, + void *(*alloc_fn)(uptr arg, SIZE_T sz), void (*free_fn)(uptr arg, void *p)) { void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, _obstack_begin_1, obstack, sz, align, alloc_fn, @@ -4884,8 +4885,10 @@ INTERCEPTOR(int, _obstack_begin_1, __sanitizer_obstack *obstack, int sz, if (res) initialize_obstack(obstack); return res; } -INTERCEPTOR(int, _obstack_begin, __sanitizer_obstack *obstack, int sz, - int align, void *(*alloc_fn)(uptr sz), void (*free_fn)(void *p)) { +INTERCEPTOR(int, _obstack_begin, __sanitizer_obstack *obstack, + _OBSTACK_SIZE_T sz, _OBSTACK_SIZE_T align, + void *(*alloc_fn)(SIZE_T sz), + void (*free_fn)(void *p)) { void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, _obstack_begin, obstack, sz, align, alloc_fn, free_fn); @@ -4893,7 +4896,8 @@ INTERCEPTOR(int, _obstack_begin, __sanitizer_obstack *obstack, int sz, if (res) initialize_obstack(obstack); return res; } -INTERCEPTOR(void, _obstack_newchunk, __sanitizer_obstack *obstack, int length) { +INTERCEPTOR(void, _obstack_newchunk, __sanitizer_obstack *obstack, + _OBSTACK_SIZE_T length) { void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, _obstack_newchunk, obstack, length); REAL(_obstack_newchunk)(obstack, length); diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac index 81fd46d..72b13a1 100644 --- a/libsanitizer/configure.ac +++ b/libsanitizer/configure.ac @@ -335,6 +335,30 @@ fi AC_SUBST([RPC_DEFS], [$rpc_defs]) +dnl If this file is processed by autoconf-2.67 or later then the CPPFLAGS +dnl "-o conftest.iii" can disappear, conftest.iii be replaced with +dnl conftest.i in the sed command line, and the rm deleted. +dnl Not all cpp's accept -o, and gcc -E does not accept a second file +dnl argument as the output file. +AC_CACHE_CHECK([obstack params], +[libsanitizer_cv_sys_obstack], +[save_cppflags=$CPPFLAGS +CPPFLAGS="-I${srcdir}/../include -o conftest.iii $CPPFLAGS" +AC_PREPROC_IFELSE([AC_LANG_SOURCE([ +#include "obstack.h" +#ifdef _OBSTACK_SIZE_T +_OBSTACK_SIZE_T +#else +int +#endif +])], +[libsanitizer_cv_sys_obstack=`sed -e '/^#/d;/^[ ]*$/d' conftest.iii | sed -e '$!d;s/size_t/SIZE_T/'`], +[libsanitizer_cv_sys_obstack=int]) +CPPFLAGS=$save_cppflags +rm -f conftest.iii +]) +AC_SUBST([OBSTACK_DEFS], [-D_OBSTACK_SIZE_T=\"$libsanitizer_cv_sys_obstack\"]) + AM_CONDITIONAL(LIBBACKTRACE_SUPPORTED, [test "x${BACKTRACE_SUPPORTED}x${BACKTRACE_USES_MALLOC}" = "x1x0"]) diff --git a/libsanitizer/asan/Makefile.am b/libsanitizer/asan/Makefile.am index bd3cd73..4500e21 100644 --- a/libsanitizer/asan/Makefile.am +++ b/libsanitizer/asan/Makefile.am @@ -3,7 +3,7 @@ AM_CPPFLAGS = -I $(top_srcdir)/include -I $(top_srcdir) # May be used by toolexeclibdir. gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) -DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DASAN_HAS_EXCEPTIONS=1 -DASAN_NEEDS_SEGV=1 -DCAN_SANITIZE_UB=0 +DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DASAN_HAS_EXCEPTIONS=1 -DASAN_NEEDS_SEGV=1 -DCAN_SANITIZE_UB=0 @OBSTACK_DEFS@ if USING_MAC_INTERPOSE DEFS += -DMAC_INTERPOSE_FUNCTIONS -DMISSING_BLOCKS_SUPPORT endif diff --git a/libsanitizer/tsan/Makefile.am b/libsanitizer/tsan/Makefile.am index 5c732cb..dc22db5 100644 --- a/libsanitizer/tsan/Makefile.am +++ b/libsanitizer/tsan/Makefile.am @@ -3,7 +3,7 @@ AM_CPPFLAGS = -I $(top_srcdir) -I $(top_srcdir)/include # May be used by toolexeclibdir. gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) -DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DCAN_SANITIZE_UB=0 +DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DCAN_SANITIZE_UB=0 @OBSTACK_DEFS@ AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long -fPIC -fno-builtin -fno-exceptions -fno-rtti -fomit-frame-pointer -funwind-tables -fvisibility=hidden -Wno-variadic-macros AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS) AM_CXXFLAGS += -std=gnu++11