WSL icon indicating copy to clipboard operation
WSL copied to clipboard

ASAN doesn't work

Open tycho opened this issue 10 years ago • 30 comments

steven@localhost ~
$ cat test2.c
int main(int argc, char **argv)
{
        return 0;
}
steven@localhost ~
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.5-2ubuntu1~14.04.1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.5 (Ubuntu 4.8.5-2ubuntu1~14.04.1)
steven@localhost ~
$ gcc -fsanitize=address -O0 -ggdb -o test2 test2.c
steven@localhost ~
$ ./test2
==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
    #0 0x7ff5fcc8231d==1910== AddressSanitizer CHECK failed: ../../../../src/libsanitizer/sanitizer_common/sanitizer_linux.cc:403 "((IsOnOf(*current_++, 's', 'p'))) != (0)" (0x0, 0x0)
^C
steven@localhost ~
$

Note that the ASAN printouts would have kept printing if I hadn't aborted with Ctrl-C.

tycho avatar Apr 11 '16 07:04 tycho

Thanks for reporting this. Could you grab a strace here to figure out what part is failing?

sunilmut avatar Apr 13 '16 06:04 sunilmut

Looks related to #120.

278   munmap(0x7ff5fbd10000, 16384)     = 0
278   mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbd10000
278   mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbcd0000
278   mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbcc0000
278   write(2, "    #0 0x7ff5fcc8231d", 21) = 21
278   munmap(0x7ff5fbcc0000, 16384)     = 0
278   mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbcc0000
278   write(2, "==278== AddressSanitizer CHECK f"..., 162) = 162
278   munmap(0x7ff5fbcc0000, 16384)     = 0
278   open("/proc/self/maps", O_RDONLY) = 3
278   mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbcc0000
278   read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096
278   close(3)                          = 0
278   open("/proc/self/maps", O_RDONLY) = 3
278   munmap(0x7ff5fbcc0000, 4096)      = 0
278   mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbcc0000
278   read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096
278   read(3, "fc1c0000-7ff5fc1c2000 rw-- 00000"..., 4096) = 4096
278   close(3)                          = 0
278   open("/proc/self/maps", O_RDONLY) = 3
278   munmap(0x7ff5fbcc0000, 8192)      = 0
278   mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbcc0000
278   read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096
278   read(3, "fc1c0000-7ff5fc1c2000 rw-- 00000"..., 4096) = 4096
278   read(3, "fda1000 rw-- 00000000 00:00 0\n7f"..., 4096) = 1330
278   read(3, 0x7ff5fbcc2532, 4096)     = 0
278   close(3)                          = 0
278   open("/proc/self/maps", O_RDONLY) = 3
278   mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbcb0000
278   read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096
278   close(3)                          = 0
278   open("/proc/self/maps", O_RDONLY) = 3
278   munmap(0x7ff5fbcb0000, 4096)      = 0
278   mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbcb0000
278   read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096
278   read(3, "fc1b0000-7ff5fc1b1000 rw-- 00000"..., 4096) = 4096
278   close(3)                          = 0
278   open("/proc/self/maps", O_RDONLY) = 3
278   munmap(0x7ff5fbcb0000, 8192)      = 0
278   mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbcb0000
278   read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096
278   read(3, "fc1b0000-7ff5fc1b1000 rw-- 00000"..., 4096) = 4096
278   read(3, "fd94000 rw-- 00000000 00:00 0\n7f"..., 4096) = 1378
278   read(3, 0x7ff5fbcb2562, 4096)     = 0
278   close(3)                          = 0
278   munmap(0x7ff5fbce0000, 16384)     = 0
278   mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbce0000
278   mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbca0000
278   mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbc90000
278   write(2, "    #0 0x7ff5fcc8231d", 21) = 21
278   munmap(0x7ff5fbc90000, 16384)     = 0
278   mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbc90000
278   write(2, "==278== AddressSanitizer CHECK f"..., 162) = 162
278   munmap(0x7ff5fbc90000, 16384)     = 0
278   open("/proc/self/maps", O_RDONLY) = 3
278   mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbc90000
278   read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096
278   close(3)                          = 0
278   open("/proc/self/maps", O_RDONLY) = 3
278   munmap(0x7ff5fbc90000, 4096)      = 0
278   mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbc90000
278   read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096
278   read(3, "fc190000-7ff5fc192000 rw-- 00000"..., 4096) = 4096
278   close(3)                          = 0
278   open("/proc/self/maps", O_RDONLY) = 3
278   munmap(0x7ff5fbc90000, 8192)      = 0
278   mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbc90000
278   read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096
278   read(3, "fc190000-7ff5fc192000 rw-- 00000"..., 4096) = 4096
278   read(3, "fd71000 rw-- 00000000 00:00 0\n7f"..., 4096) = 1474
278   read(3, 0x7ff5fbc925c2, 4096)     = 0
278   close(3)                          = 0
278   open("/proc/self/maps", O_RDONLY) = 3
278   mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbc80000
278   read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096
278   --- SIGINT {si_signo=SIGINT, si_code=SI_KERNEL} ---                                                                                                                                                                                                                                   278   mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbd10000                                                                                                                                                                               278   mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbcd0000                                                                                                                                                                               278   mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbcc0000                                                                                                                                                                              278   write(2, "    #0 0x7ff5fcc8231d", 21) = 21                                                                                                                                                                                                                              278   munmap(0x7ff5fbcc0000, 16384)     = 0                                                                                                                                                                                                                                   278   mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbcc0000                                                                                                                                                                              278   write(2, "==278== AddressSanitizer CHECK f"..., 162) = 162                                                                                                                                                                                                              278   munmap(0x7ff5fbcc0000, 16384)     = 0                                                                                                                                                                                                                                   278   open("/proc/self/maps", O_RDONLY) = 3                                                                                                                                                                                                                                   278   mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbcc0000                                                                                                                                                                               278   read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096                                                                                                                                                                                                             278   close(3)                          = 0                                                                                                                                                                                                                                   278   open("/proc/self/maps", O_RDONLY) = 3                                                                                                                                                                                                                                   278   munmap(0x7ff5fbcc0000, 4096)      = 0                                                                                                                                                                                                                                   278   mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbcc0000                                                                                                                                                                               278   read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096                                                                                                                                                                                                             278   read(3, "fc1c0000-7ff5fc1c2000 rw-- 00000"..., 4096) = 4096                                                                                                                                                                                                             278   close(3)                          = 0                                                                                                                                                                                                                                   278   open("/proc/self/maps", O_RDONLY) = 3                                                                                                                                                                                                                                   278   munmap(0x7ff5fbcc0000, 8192)      = 0                                                                                                                                                                                                                                   278   mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbcc0000                                                                                                                                                                              278   read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096                                                                                                                                                                                                             278   read(3, "fc1c0000-7ff5fc1c2000 rw-- 00000"..., 4096) = 4096                                                                                                                                                                                                             278   read(3, "fda1000 rw-- 00000000 00:00 0\n7f"..., 4096) = 1330                                                                                                                                                                                                            278   read(3, 0x7ff5fbcc2532, 4096)     = 0                                                                                                                                                                                                                                   278   close(3)                          = 0                                                                                                                                                                                                                                   278   open("/proc/self/maps", O_RDONLY) = 3                                                                                                                                                                                                                                   278   mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbcb0000                                                                                                                                                                               278   read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096                                                                                                                                                                                                             278   close(3)                          = 0                                                                                                                                                                                                                                   278   open("/proc/self/maps", O_RDONLY) = 3                                                                                                                                                                                                                                   278   munmap(0x7ff5fbcb0000, 4096)      = 0                                                                                                                                                                                                                                   278   mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbcb0000                                                                                                                                                                               278   read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096                                                                                                                                                                                                             278   read(3, "fc1b0000-7ff5fc1b1000 rw-- 00000"..., 4096) = 4096                                                                                                                                                                                                             278   close(3)                          = 0                                                                                                                                                                                                                                   278   open("/proc/self/maps", O_RDONLY) = 3                                                                                                                                                                                                                                   278   munmap(0x7ff5fbcb0000, 8192)      = 0                                                                                                                                                                                                                                   278   mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbcb0000                                                                                                                                                                              278   read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096                                                                                                                                                                                                             278   read(3, "fc1b0000-7ff5fc1b1000 rw-- 00000"..., 4096) = 4096                                                                                                                                                                                                             278   read(3, "fd94000 rw-- 00000000 00:00 0\n7f"..., 4096) = 1378                                                                                                                                                                                                            278   read(3, 0x7ff5fbcb2562, 4096)     = 0                                                                                                                                                                                                                                   278   close(3)                          = 0                                                                                                                                                                                                                                   278   munmap(0x7ff5fbce0000, 16384)     = 0                                                                                                                                                                                                                                   278   mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbce0000                                                                                                                                                                               278   mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbca0000                                                                                                                                                                               278   mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbc90000                                                                                                                                                                              278   write(2, "    #0 0x7ff5fcc8231d", 21) = 21                                                                                                                                                                                                                              278   munmap(0x7ff5fbc90000, 16384)     = 0                                                                                                                                                                                                                                   278   mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbc90000                                                                                                                                                                              278   write(2, "==278== AddressSanitizer CHECK f"..., 162) = 162                                                                                                                                                                                                              278   munmap(0x7ff5fbc90000, 16384)     = 0                                                                                                                                                                                                                                   278   open("/proc/self/maps", O_RDONLY) = 3                                                                                                                                                                                                                                   278   mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbc90000                                                                                                                                                                               278   read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096                                                                                                                                                                                                             278   close(3)                          = 0                                                                                                                                                                                                                                   278   open("/proc/self/maps", O_RDONLY) = 3                                                                                                                                                                                                                                   278   munmap(0x7ff5fbc90000, 4096)      = 0                                                                                                                                                                                                                                   278   mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbc90000                                                                                                                                                                               278   read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096                                                                                                                                                                                                             278   read(3, "fc190000-7ff5fc192000 rw-- 00000"..., 4096) = 4096                                                                                                                                                                                                             278   close(3)                          = 0                                                                                                                                                                                                                                   278   open("/proc/self/maps", O_RDONLY) = 3                                                                                                                                                                                                                                   278   munmap(0x7ff5fbc90000, 8192)      = 0                                                                                                                                                                                                                                   278   mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbc90000                                                                                                                                                                              278   read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096                                                                                                                                                                                                             278   read(3, "fc190000-7ff5fc192000 rw-- 00000"..., 4096) = 4096                                                                                                                                                                                                             278   read(3, "fd71000 rw-- 00000000 00:00 0\n7f"..., 4096) = 1474                                                                                                                                                                                                            278   read(3, 0x7ff5fbc925c2, 4096)     = 0                                                                                                                                                                                                                                   278   close(3)                          = 0                                                                                                                                                                                                                                   278   open("/proc/self/maps", O_RDONLY) = 3                                                                                                                                                                                                                                   278   mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff5fbc80000                                                                                                                                                                               278   read(3, "00400000-00401000 r-x- 00000000 "..., 4096) = 4096                                                                                                                                                                                                             278   --- SIGINT {si_signo=SIGINT, si_code=SI_KERNEL} --- 

It keeps reading /proc/self/maps in hoping -something- has changed, but I'm not sure what it's looking for.

tycho avatar Apr 17 '16 06:04 tycho

Entry for same bug in asan bug tracker: https://github.com/google/sanitizers/issues/708

Still occurs on Windows 14393.105

Meinersbur avatar Sep 02 '16 12:09 Meinersbur

Some information about the issue. ASAN expects procmaps to be formatted as follows 08048000-08056000 r-xp 00000000 03:0c 64593 /foo/bar It fails on the last char of permissions part. It expects either s or p. On Windows information whether mapping is shared or private is not available and - is shown instead, which triggers assert here https://github.com/llvm-mirror/compiler-rt/blob/74c8f498fa128f0cd4eb97d603c017f250dd3694/lib/sanitizer_common/sanitizer_procmaps_linux.cc#L59

Can we expect this to be fixed? Seems like not a big bug to fix. Mapping need to be either private or shared so showing - is just silly.

Example of output on Windows:

$ cat /proc/self/maps
00400000-0040c000 r-x- 00000000 00:00 7623                       /bin/cat
0060b000-0060c000 r--- 0000b000 00:00 7623                       /bin/cat
0060c000-0060d000 rw-- 0000c000 00:00 7623                       /bin/cat
00bcb000-00bec000 rw-- 00000000 00:00 0                          [heap]
7f1976a30000-7f1976bef000 r-x- 00000000 00:00 202985             /lib/x86_64-linux-gnu/libc-2.23.so
7f1976bef000-7f1976bf8000 ---- 001bf000 00:00 202985             /lib/x86_64-linux-gnu/libc-2.23.so
7f1976bf8000-7f1976def000 ---- 00000000 00:00 0
7f1976def000-7f1976df3000 r--- 001bf000 00:00 202985             /lib/x86_64-linux-gnu/libc-2.23.so
7f1976df3000-7f1976df5000 rw-- 001c3000 00:00 202985             /lib/x86_64-linux-gnu/libc-2.23.so
7f1976df5000-7f1976df9000 rw-- 00000000 00:00 0
7f1976e00000-7f1976e26000 r-x- 00000000 00:00 203030             /lib/x86_64-linux-gnu/ld-2.23.so
7f1977000000-7f1977022000 rw-- 00000000 00:00 0
7f1977025000-7f1977026000 r--- 00025000 00:00 203030             /lib/x86_64-linux-gnu/ld-2.23.so
7f1977026000-7f1977027000 rw-- 00026000 00:00 203030             /lib/x86_64-linux-gnu/ld-2.23.so
7f1977027000-7f1977028000 rw-- 00000000 00:00 0
7f1977028000-7f19771c0000 r--- 00000000 00:00 22408              /usr/lib/locale/locale-archive
7f19771c0000-7f19771c1000 rw-- 00000000 00:00 0
7f19771d0000-7f19771d1000 rw-- 00000000 00:00 0
7f19771e0000-7f19771e1000 rw-- 00000000 00:00 0
7f19771f0000-7f19771f2000 rw-- 00000000 00:00 0
7ffffe41e000-7ffffec1e000 rw-- 00000000 00:00 0                  [stack]
7fffff2d8000-7fffff2d9000 r-x- 00000000 00:00 0                  [vdso]

kasper93 avatar Apr 20 '17 21:04 kasper93

I changed ASAN to accept Window's proc maps format. But it is still unusable. ASAN maps 20TB of virtual memory and it kills WSL. It is so slow that asan init code takes hours. Probably the same issue as https://github.com/Microsoft/BashOnWindows/issues/1671

kasper93 avatar Apr 21 '17 21:04 kasper93

Would be great, if we could run ASAN (and the other sanitizers) on WSL.

MikeGitb avatar Aug 25 '17 16:08 MikeGitb

Using 16299 it seems to get further now.

My code

#include <string.h>

int main() {
	char arr[2];
	strcpy(arr, "str");
	return 0;
}

Using the following command-line

gcc -fsanitize=address crash.c -o crash

Reports this

==3969==ERROR: AddressSanitizer failed to allocate 0xdfff0001000 (15392894357504) bytes at address 2008fff7000 (errno: 12) ==3969==ReserveShadowMemoryRange failed while trying to map 0xdfff0001000 bytes. Perhaps you're using ulimit -v Aborted (core dumped)

The strange output: strace.log

Seems like the interesting part

setrlimit(RLIMIT_CORE, {rlim_cur=0, rlim_max=0}) = 0 mmap(0x7fff7000, 268435456, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x7fff7000 mmap(0x2008fff7000, 15392894357504, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = -1 ENOMEM (Cannot allocate memory)

The same issue seems to apply using MemorySanitizer with clang:

==6442==ERROR: MemorySanitizer failed to allocate 0xf0000000000 (16492674416640) bytes at address 10000000000 (errno: 12)

Using

clang -fsanitize=memory crash.c -o crash

Both of these return immediately.

The problem with the long start-up because of mapping memory still seems to happen when using ThreadSanitizer (GCC and clang) though.

Using

gcc -fsanitize=thread crash.c -o crash

Or

clang -fsanitize=thread crash.c -o crash

firewave avatar Oct 20 '17 12:10 firewave

Looking into this a bit, the behavior of mmap for large regions with MAP_NORESERVE is somewhat odd.

This code fails on my system with #if 0 but succeeds, although mmap & mprotect take tens of seconds each, with #if 1:

#include <sys/mman.h>
#include <stdio.h>

int main()
{
	size_t size = 0xdfff0001000;

#if 1
	void* ptr = mmap(0, size, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0);
	printf("mmap => %p\n", ptr);
	int rc = mprotect(ptr, size, PROT_READ|PROT_WRITE);
	printf("mprotect => %d\n", rc);
#else
	void* ptr = mmap(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0);
	printf("mmap => %p\n", ptr);
#endif
}

As far as I can tell the memory mapped is completely usable after mprotect; it might be a reasonable workaround for asan even though it takes close to a minute to start up. This is on Windows 10 build 16299.19

zeux avatar Oct 30 '17 04:10 zeux

Hey all - suggestion from one of our devs: For the memory issue, try setting /proc/sys/vm/overcommit_memory to 1.

And do let us know if this helps!

/cc @MikeGitb

bitcrazed avatar Nov 09 '17 00:11 bitcrazed

@bitcrazed Thanks! This fixes the mmap error and lets me run asan. At the end of the run (at least with my test program) I get this output: "LeakSanitizer has encountered a fatal error", but that's at exit so it's not as pressing.

A more significant issue now that asan startup is unblocked is performance; for my test program, ASAN run takes 19m30s and non-ASAN run takes 150ms. Valgrind run of a non-ASAN build takes 3 seconds.

zeux avatar Nov 09 '17 04:11 zeux

Curiously, most of the time seems to be spent reading /proc/self/maps, not doing actual mmap; attaching strace output.

asan-trace.txt

zeux avatar Nov 09 '17 05:11 zeux

It's the mmap after the reading of /proc/self/maps for me - so MSAN and ASAN binaries now start up and behave like TSAN ones. I only tested it with GCC.

firewave avatar Nov 09 '17 11:11 firewave

Like I said few months ago, ASAN is affected by https://github.com/Microsoft/WSL/issues/1671 like many other tools that maps large amount of memory. Until that's fixed I doubt it will be usable.

kasper93 avatar Nov 09 '17 18:11 kasper93

FYI.

From issue #1671

We have improved mmap performance further in insider build 17063. I believe this makes stack ghc bearable to use now :).

This should significantly help sanitizers performance too.

kasper93 avatar Dec 19 '17 22:12 kasper93

With build 17063, the performance issues with asan seem to have been resolved - I still need to set overcommit_memory to 1, but after that it runs fine with good performance (~600ms vs ~150ms for non-asan run which seems reasonable).

There's still one issue at the end of execution:

==3742==Failed spawning a tracer thread (errno 22).
==3742==LeakSanitizer has encountered a fatal error.
==3742==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
==3742==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)

zeux avatar Dec 22 '17 19:12 zeux

Running the program under strace (yeah I know the hint says "LeakSanitizer does not work under ptrace" :D) produces this syscall right before the fatal error:

clone(child_stack=0x7f3765120ff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_UNTRACED) = -1 
EINVAL (Invalid argument)

Since errno 22 is EINVAL this might be the cause.

zeux avatar Dec 22 '17 19:12 zeux

They fixed issues with both CLONE and EINVAL in previous Insider builds. I would submit a ticket to the package developer and get their input on it.

Edit: Unless something regressed due to the huge changes to 17063.

WSLUser avatar Dec 22 '17 19:12 WSLUser

This program does reproduce the behavior (printing -1 on WSL, and a non-negative id on regular Linux):

#include <assert.h>
#include <sys/mman.h>
#include <unistd.h>
#include <sched.h>
#include <stdio.h>

int TracerThread(void *)
{
	return 0;
}

int main()
{
	const unsigned kStackSize = 2 * 1024 * 1024;
	void* stack = mmap(0, kStackSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
	pid_t tracer_pid = clone(TracerThread, (char*)stack + kStackSize, CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_UNTRACED, 0);
	printf("tracer pid: %d\n", int(tracer_pid));
}

So I would guess that this is a WSL issue with clone. I will file a separate issue for this.

zeux avatar Dec 22 '17 19:12 zeux

The OP here was referring /proc/self/maps not being formatted correctly, described in #708 (comment) and addressed in 16215. Performance issues can be tracked in #1671. Running ASAN under strace can be tracked in #2781. That leaves MAP_NORESERVE AFAICT.

therealkenc avatar Dec 22 '17 23:12 therealkenc

I filed MAP_NORESERVE issue separately as #2784.

zeux avatar Dec 23 '17 05:12 zeux