boards/native: fix crash with all-asan
Without this change a RIOT application compiled with all-asan will segfault as RIOT provides its own malloc by default. Add a define for disabling custom malloc, calloc and realloc implementations and use it when compiling with all-asan.
This commit is contained in:
parent
be0a24e532
commit
e2b8231796
@ -98,7 +98,7 @@ all-cachegrind: CFLAGS += -g3
|
|||||||
all-gprof: CFLAGS += -pg
|
all-gprof: CFLAGS += -pg
|
||||||
all-gprof: LINKFLAGS += -pg
|
all-gprof: LINKFLAGS += -pg
|
||||||
all-asan: CFLAGS += -fsanitize=address -fno-omit-frame-pointer -g3
|
all-asan: CFLAGS += -fsanitize=address -fno-omit-frame-pointer -g3
|
||||||
all-asan: CFLAGS += -DNATIVE_IN_CALLOC
|
all-asan: CFLAGS += -DNATIVE_MEMORY
|
||||||
all-asan: LINKFLAGS += -fsanitize=address -fno-omit-frame-pointer -g3
|
all-asan: LINKFLAGS += -fsanitize=address -fno-omit-frame-pointer -g3
|
||||||
|
|
||||||
INCLUDES += $(NATIVEINCLUDES)
|
INCLUDES += $(NATIVEINCLUDES)
|
||||||
|
|||||||
@ -142,7 +142,7 @@ void _native_syscall_leave(void)
|
|||||||
/* make use of TLSF if it is included, except when building with valgrind
|
/* make use of TLSF if it is included, except when building with valgrind
|
||||||
* support, where one probably wants to make use of valgrind's memory leak
|
* support, where one probably wants to make use of valgrind's memory leak
|
||||||
* detection abilities*/
|
* detection abilities*/
|
||||||
#if !(defined MODULE_TLSF) || (defined(HAVE_VALGRIND_H))
|
#if (!(defined MODULE_TLSF) && !(defined NATIVE_MEMORY)) || (defined(HAVE_VALGRIND_H))
|
||||||
int _native_in_malloc = 0;
|
int _native_in_malloc = 0;
|
||||||
void *malloc(size_t size)
|
void *malloc(size_t size)
|
||||||
{
|
{
|
||||||
@ -176,11 +176,7 @@ void free(void *ptr)
|
|||||||
_native_syscall_leave();
|
_native_syscall_leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NATIVE_IN_CALLOC
|
|
||||||
int _native_in_calloc = 1;
|
|
||||||
#else
|
|
||||||
int _native_in_calloc = 0;
|
int _native_in_calloc = 0;
|
||||||
#endif
|
|
||||||
void *calloc(size_t nmemb, size_t size)
|
void *calloc(size_t nmemb, size_t size)
|
||||||
{
|
{
|
||||||
/* dynamically load calloc when it's needed - this is necessary to
|
/* dynamically load calloc when it's needed - this is necessary to
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user