diff --git a/Makefile b/Makefile index 9ffb60634..dfa4ed623 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ ifeq ($(DO_ASAN_FLAGS),1) ASAN_FLAGS = -ggdb -O0 -fsanitize=address -fsanitize=leak -fsanitize=undefined CFLAGS ?= -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wstrict-prototypes CFLAGS += $(ASAN_FLAGS) +CFLAGS += -DASAN_BUILD LDFLAGS += $(ASAN_FLAGS) export CFLAGS export LDFLAGS diff --git a/daemon/aux.c b/daemon/aux.c index fb4ebe821..88e68025d 100644 --- a/daemon/aux.c +++ b/daemon/aux.c @@ -246,9 +246,15 @@ static void *thread_detach_func(void *d) { dt->priority, strerror(errno)); } +#ifndef ASAN_BUILD pthread_cleanup_push(thread_detach_cleanup, dt); +#endif dt->func(dt->data); +#ifndef ASAN_BUILD pthread_cleanup_pop(true); +#else + thread_detach_cleanup(dt); +#endif return NULL; } diff --git a/include/aux.h b/include/aux.h index 32126831f..0dffb50f6 100644 --- a/include/aux.h +++ b/include/aux.h @@ -349,9 +349,15 @@ INLINE void thread_create_detach(void (*f)(void *), void *a, const char *name) { thread_create_detach_prio(f, a, NULL, 0, name); } +#ifndef ASAN_BUILD #define thread_cancel_enable() pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) #define thread_cancel_disable() pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL) #define thread_sleep_time 10000 /* ms */ +#else +#define thread_cancel_enable() ((void)0) +#define thread_cancel_disable() ((void)0) +#define thread_sleep_time 100 /* ms */ +#endif