MT#55524 work around buggy libasan

On bookworm and later, libasan reports a false positive in combination
with pthread_cleanup_push() (see [1]). Work around this by not using the
thread cleanup handler when running the asan build, and instead use a
shorter thread sleep time.

[1] https://gcc.gnu.org/bugzilla//show_bug.cgi?id=82109

Change-Id: Ieffdc0b13f470445f1f8e1d2448c6af6d8dd68e0
(cherry picked from commit c9a5714df7)
mr10.5.3
Richard Fuchs 2 years ago
parent 8fec5d353b
commit 995d50b555

@ -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

@ -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;
}

@ -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

Loading…
Cancel
Save