Search code examples
c++dockeraddress-sanitizer

How to get ASan working with a 4.12.3 Linux kernel?


I'm trying to set up / fix asan in my docker container. For this I use a trivial example program

int main() { return 16; }

And compile it with

clang++ -std=c++1z -O1 -fsanitize=address test.cpp

With clang 4.0.1 (it makes no difference which -std I use).

This produces the error with a 4.12.3-1-ARCH kernel version, and none of the things I pulled of google or the asan FAQ seem to change this.

$ ./a.out 
==13178==Shadow memory range interleaves with an existing memory mapping. ASan cannot proceed correctly. ABORTING.
==13178==ASan shadow was supposed to be located in the [0x00007fff7000-0x10007fff7fff] range.
==13178==Process memory map follows:
    0x00eda9b0a000-0x00eda9c4e000   /tmp/a.out
    0x00eda9e4e000-0x00eda9e4f000   /tmp/a.out
    0x00eda9e4f000-0x00eda9e52000   /tmp/a.out
    0x00eda9e52000-0x00edaab37000   
    0x7f4266de9000-0x7f426713b000   
    0x7f426713b000-0x7f42672d8000   /usr/lib/libc-2.25.so
    0x7f42672d8000-0x7f42674d7000   /usr/lib/libc-2.25.so
    0x7f42674d7000-0x7f42674db000   /usr/lib/libc-2.25.so
    0x7f42674db000-0x7f42674dd000   /usr/lib/libc-2.25.so
    0x7f42674dd000-0x7f42674e1000   
    0x7f42674e1000-0x7f42674f7000   /usr/lib/libgcc_s.so.1
    0x7f42674f7000-0x7f42676f6000   /usr/lib/libgcc_s.so.1
    0x7f42676f6000-0x7f42676f7000   /usr/lib/libgcc_s.so.1
    0x7f42676f7000-0x7f42676f8000   /usr/lib/libgcc_s.so.1
    0x7f42676f8000-0x7f42676fb000   /usr/lib/libdl-2.25.so
    0x7f42676fb000-0x7f42678fa000   /usr/lib/libdl-2.25.so
    0x7f42678fa000-0x7f42678fb000   /usr/lib/libdl-2.25.so
    0x7f42678fb000-0x7f42678fc000   /usr/lib/libdl-2.25.so
    0x7f42678fc000-0x7f4267903000   /usr/lib/librt-2.25.so
    0x7f4267903000-0x7f4267b02000   /usr/lib/librt-2.25.so
    0x7f4267b02000-0x7f4267b03000   /usr/lib/librt-2.25.so
    0x7f4267b03000-0x7f4267b04000   /usr/lib/librt-2.25.so
    0x7f4267b04000-0x7f4267b1d000   /usr/lib/libpthread-2.25.so
    0x7f4267b1d000-0x7f4267d1c000   /usr/lib/libpthread-2.25.so
    0x7f4267d1c000-0x7f4267d1d000   /usr/lib/libpthread-2.25.so
    0x7f4267d1d000-0x7f4267d1e000   /usr/lib/libpthread-2.25.so
    0x7f4267d1e000-0x7f4267d22000   
    0x7f4267d22000-0x7f4267e33000   /usr/lib/libm-2.25.so
    0x7f4267e33000-0x7f4268032000   /usr/lib/libm-2.25.so
    0x7f4268032000-0x7f4268033000   /usr/lib/libm-2.25.so
    0x7f4268033000-0x7f4268034000   /usr/lib/libm-2.25.so
    0x7f4268034000-0x7f42681ae000   /usr/lib/libstdc++.so.6.0.24
    0x7f42681ae000-0x7f42683ad000   /usr/lib/libstdc++.so.6.0.24
    0x7f42683ad000-0x7f42683b7000   /usr/lib/libstdc++.so.6.0.24
    0x7f42683b7000-0x7f42683b9000   /usr/lib/libstdc++.so.6.0.24
    0x7f42683b9000-0x7f42683bc000   
    0x7f42683bc000-0x7f42683df000   /usr/lib/ld-2.25.so
    0x7f42685b7000-0x7f42685c9000   
    0x7f42685cb000-0x7f42685da000   
    0x7f42685da000-0x7f42685df000   
    0x7f42685df000-0x7f42685e0000   /usr/lib/ld-2.25.so
    0x7f42685e0000-0x7f42685e1000   /usr/lib/ld-2.25.so
    0x7f42685e1000-0x7f42685e2000   
    0x7ffda4652000-0x7ffda4673000   [stack]
    0x7ffda46cc000-0x7ffda46cf000   [vvar]
    0x7ffda46cf000-0x7ffda46d1000   [vdso]
    0xffffffffff600000-0xffffffffff601000   [vsyscall]
==13178==End of process memory map.

Solution

  • This is fixed at least since kernel version 4.12.10-1-ARCH.

    Also (apparently) newer compiler versions work but I didn't test this personally.