cat aligned_alloc.c #include <stdlib.h> int main(void) { void * p = aligned_alloc(128, 1024); free(p); } $ gcc -std=c11 -fsanitize=address aligned_alloc.c && ./a.out ================================================================= ==28341==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x000000728080 in thread T0 #0 0x7fa78060d2d7 in __interceptor_free ../../../../gcc/libsanitizer/asan/asan_malloc_linux.cc:62 #1 0x40077e in main (/home/lgb/Development/test/a.out+0x40077e) #2 0x31c0821d64 in __libc_start_main (/lib64/libc.so.6+0x31c0821d64) #3 0x400688 (/home/lgb/Development/test/a.out+0x400688) AddressSanitizer can not describe address in more detail (wild memory access suspected). SUMMARY: AddressSanitizer: bad-free ../../../../gcc/libsanitizer/asan/asan_malloc_linux.cc:62 __interceptor_free ==28341==ABORTING AFAICS the asan interceptor for aligned_alloc is missing.
Interesting. This is a relatively new c11 feature. On older Linux distros this does not compile nor link: aligned_alloc.c: In function ‘main’: aligned_alloc.c:5:3: warning: implicit declaration of function ‘aligned_alloc’ [-Wimplicit-function-declaration] void * p = aligned_alloc(128, 1024); ... /tmp/ccJJcsqx.o: In function `main': aligned_alloc.c:(.text+0x13): undefined reference to `aligned_alloc' On Ubuntu 14.04 it behaves as you describe and indeed we need to add an interceptor. The tricky part is to add a test that will work on older distros
Just declare it yourself? If libasan always contains the aligned_alloc symbol, then the testcase will link even when system glibc does not contain it...
yep, that's the plan...
http://llvm.org/viewvc/llvm-project?view=revision&revision=212322 implements aligned_alloc support on Linux. I will let others implement Android/Windows/Mac support if relevant. This will reach GCC with the next libsanitizer merge (not sure when), or feel free to cherry pick in a couple of days (to make sure it works well)
Has been fixed in r215527. Close?
Fixed.