Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSAN reports false-positive with TLS #52872

Open
olologin opened this issue Dec 25, 2021 · 1 comment
Open

MSAN reports false-positive with TLS #52872

olologin opened this issue Dec 25, 2021 · 1 comment
Labels
compiler-rt:msan Memory sanitizer

Comments

@olologin
Copy link

olologin commented Dec 25, 2021

Hi everyone, MSAN is reporting false-positive with latest build of clang-14 (and with clang-12).
Is it because some interceptor implementation is missing?
I also tested it in valgrind but everything is fine with this code.

Test: https://github.com/llvm/llvm-project/blob/main/compiler-rt/test/msan/dtls_test.c

OS is debian buster, glibc is 2.28, using latest build of clang.
Also tried on debian bullseye, same result.

root@b30e30645388:/build/build# clang-14 -fPIC -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -g dtls_test.c -o main
root@b30e30645388:/build/build# clang-14 -fPIC -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -g dtls_test.c -DBUILD_SO -o main-so.so -shared
root@b30e30645388:/build/build# ./main
==24099==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x4a50a1 in Thread1 /build/build/dtls_test.c:33:7
    #1 0x7fc496fd2fa2 in start_thread /build/glibc-vjB4T1/glibc-2.28/nptl/pthread_create.c:486:8
    #2 0x7fc496d574ce in __clone /build/glibc-vjB4T1/glibc-2.28/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95

  Uninitialized value was created by a heap allocation
    #0 0x4537e0 in __interceptor_malloc (/build/build/main+0x4537e0) (BuildId: c53a116747654387bfa98d19a266e2b2ba84a1a2)
    #1 0x7fc4970088b7 in allocate_dtv_entry /build/glibc-vjB4T1/glibc-2.28/elf/../elf/dl-tls.c:582:19
    #2 0x7fc4970088b7 in allocate_and_init /build/glibc-vjB4T1/glibc-2.28/elf/../elf/dl-tls.c:607:31
    #3 0x7fc4970088b7 in tls_get_addr_tail /build/glibc-vjB4T1/glibc-2.28/elf/../elf/dl-tls.c:787:31

SUMMARY: MemorySanitizer: use-of-uninitialized-value /build/build/dtls_test.c:33:7 in Thread1
Exiting
root@b30e30645388:/build/build# ldd ./main
        linux-vdso.so.1 (0x00007ffec9d19000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f41f9e10000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f41f9e06000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f41f9c83000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f41f9c7e000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f41f9c64000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f41f9aa3000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f41f9e3c000)

Duplicate of google/sanitizers#1478

@olologin olologin changed the title MSAN reports false-positive when TLS is used MSAN reports false-positive with TLS Dec 25, 2021
@dvyukov
Copy link
Collaborator

dvyukov commented Dec 25, 2021

FWIW I recently found that DTLS support in sanitizers is broken:
https://bugs.chromium.org/p/chromium/issues/detail?id=1275223#c15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler-rt:msan Memory sanitizer
Projects
None yet
Development

No branches or pull requests

3 participants