This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] [Sanitizers] Extend ThreadDescriptorSize() for glibc-2.32-2.fc33.x86_64+i686
ClosedPublic

Authored by jankratochvil on Dec 16 2020, 2:43 AM.

Details

Summary

before:

$ echo 'int main(){}'|clang -g -fsanitize=leak -x c++ -;./a.out
Tracer caught signal 11: addr=0x7f4f73da5f40 pc=0x4222c8 sp=0x7f4f72cffd40
==1164171==LeakSanitizer has encountered a fatal error.
==1164171==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
==1164171==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)
$ _

after:

$ echo 'int main(){}'|clang -g -fsanitize=leak -x c++ -;./a.out)
$ _

Unfortunately I do not have it reproducible on a different box than two my boxes (even not in my VM).
I haven't verified the size cannot be affected by Fedora patches of upstream glibc-2.32 - but I do not expect upstream glibc-2.32 would have the last sizes (1216, 2304) from 2013 around glibc-2.12.
There should be some better (at least build-time) verification of the size.

Diff Detail

Event Timeline

jankratochvil created this revision.Dec 16 2020, 2:43 AM
jankratochvil requested review of this revision.Dec 16 2020, 2:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 16 2020, 2:43 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript

We have TEST(SanitizerLinux, ThreadDescriptorSize)
Do you know if it fails on your boxes?

compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
297

please fix these clang-format warnings

jankratochvil marked an inline comment as done.Dec 29 2020, 5:18 AM

We have TEST(SanitizerLinux, ThreadDescriptorSize)
Do you know if it fails on your boxes?

Thanks for the review. Yes, this patch changes the testsuite results from:

Failed Tests (81):
  SanitizerCommon-Unit :: ./Sanitizer-i386-Test/SanitizerLinux.ThreadDescriptorSize
  SanitizerCommon-Unit :: ./Sanitizer-x86_64-Test/SanitizerLinux.ThreadDescriptorSize
  SanitizerCommon-asan-x86_64-Linux :: Linux/getpwnam_r_invalid_user.cpp
  SanitizerCommon-lsan-i386-Linux :: Linux/aligned_alloc-alignment.cpp
  SanitizerCommon-lsan-i386-Linux :: Linux/allow_user_segv.cpp
  SanitizerCommon-lsan-i386-Linux :: Linux/clock_gettime.c
  SanitizerCommon-lsan-i386-Linux :: Linux/closedir.c
  SanitizerCommon-lsan-i386-Linux :: Linux/crypt_r.cpp
  SanitizerCommon-lsan-i386-Linux :: Linux/decorate_proc_maps.cpp
  SanitizerCommon-lsan-i386-Linux :: Linux/mallopt.cpp
  SanitizerCommon-lsan-i386-Linux :: Linux/mmap64_test.c
  SanitizerCommon-lsan-i386-Linux :: Linux/new_delete_test.cpp
  SanitizerCommon-lsan-i386-Linux :: Linux/pthread_mutex.cpp
  SanitizerCommon-lsan-i386-Linux :: Linux/ptrace.cpp
  SanitizerCommon-lsan-i386-Linux :: Linux/ptsname.c
  SanitizerCommon-lsan-i386-Linux :: Linux/pvalloc-overflow.cpp
  SanitizerCommon-lsan-i386-Linux :: Linux/recv_msg_trunc.cpp
  SanitizerCommon-lsan-i386-Linux :: Linux/sched_getparam.cpp
  SanitizerCommon-lsan-i386-Linux :: Linux/signal_segv_handler.cpp
  SanitizerCommon-lsan-i386-Linux :: Linux/sysconf_interceptor_bypass_test.cpp
  SanitizerCommon-lsan-i386-Linux :: Linux/sysmsg.c
  SanitizerCommon-lsan-i386-Linux :: Linux/timerfd.cpp
  SanitizerCommon-lsan-i386-Linux :: Posix/access.cpp
  SanitizerCommon-lsan-i386-Linux :: Posix/crypt.cpp
  SanitizerCommon-lsan-i386-Linux :: Posix/fgetc_ungetc_getc.cpp
  SanitizerCommon-lsan-i386-Linux :: Posix/fputc_putc_putchar.cpp
  SanitizerCommon-lsan-i386-Linux :: Posix/fputs_puts.cpp
  SanitizerCommon-lsan-i386-Linux :: Posix/getc_unlocked.cpp
  SanitizerCommon-lsan-i386-Linux :: Posix/getpass.cpp
  SanitizerCommon-lsan-i386-Linux :: Posix/getrandom.c
  SanitizerCommon-lsan-i386-Linux :: Posix/lstat.cpp
  SanitizerCommon-lsan-i386-Linux :: Posix/popen.cpp
  SanitizerCommon-lsan-i386-Linux :: Posix/posix_memalign-alignment.cpp
  SanitizerCommon-lsan-i386-Linux :: Posix/putc_putchar_unlocked.cpp
  SanitizerCommon-lsan-i386-Linux :: Posix/readlink.c
  SanitizerCommon-lsan-i386-Linux :: Posix/recursion-in-qsort.cpp
  SanitizerCommon-lsan-i386-Linux :: Posix/regex.cpp
  SanitizerCommon-lsan-i386-Linux :: Posix/sanitizer_set_report_path_test.cpp
  SanitizerCommon-lsan-i386-Linux :: Posix/strxfrm.c
  SanitizerCommon-lsan-i386-Linux :: Posix/uname.c
  SanitizerCommon-lsan-i386-Linux :: Posix/wcsdup.c
  SanitizerCommon-lsan-i386-Linux :: allocator_returns_null.cpp
  SanitizerCommon-lsan-i386-Linux :: ctype.c
  SanitizerCommon-lsan-i386-Linux :: fopen_nullptr.c
  SanitizerCommon-lsan-i386-Linux :: max_allocation_size.cpp
  SanitizerCommon-lsan-i386-Linux :: onprint.cpp
  SanitizerCommon-lsan-i386-Linux :: options-help.cpp
  SanitizerCommon-lsan-i386-Linux :: options-include.cpp
  SanitizerCommon-lsan-i386-Linux :: options-invalid.cpp
  SanitizerCommon-lsan-i386-Linux :: printf-ldbl.c
  SanitizerCommon-lsan-i386-Linux :: pthread_mutexattr_get.cpp
  SanitizerCommon-lsan-i386-Linux :: reallocarray-overflow.cpp
  SanitizerCommon-lsan-i386-Linux :: sanitizer_coverage_inline8bit_counter.cpp
  SanitizerCommon-lsan-i386-Linux :: sanitizer_coverage_inline_bool_flag.cpp
  SanitizerCommon-lsan-i386-Linux :: sanitizer_coverage_stack_depth.cpp
  SanitizerCommon-lsan-i386-Linux :: sanitizer_coverage_trace_pc_guard.cpp
  SanitizerCommon-lsan-i386-Linux :: strcspn.c
  SanitizerCommon-lsan-i386-Linux :: strnlen.c
  SanitizerCommon-lsan-i386-Linux :: strspn.c
  SanitizerCommon-lsan-i386-Linux :: wcrtomb.c
  SanitizerCommon-lsan-i386-Linux :: wctomb.c
  SanitizerCommon-lsan-x86_64-Linux :: Linux/clock_gettime.c
  SanitizerCommon-lsan-x86_64-Linux :: Linux/closedir.c
  SanitizerCommon-lsan-x86_64-Linux :: Linux/getcpuclockid.c
  SanitizerCommon-lsan-x86_64-Linux :: Linux/mmap64_test.c
  SanitizerCommon-lsan-x86_64-Linux :: Linux/ptsname.c
  SanitizerCommon-lsan-x86_64-Linux :: Linux/sysmsg.c
  SanitizerCommon-lsan-x86_64-Linux :: Posix/getrandom.c
  SanitizerCommon-lsan-x86_64-Linux :: Posix/mmap_test.c
  SanitizerCommon-lsan-x86_64-Linux :: Posix/readlink.c
  SanitizerCommon-lsan-x86_64-Linux :: Posix/readlinkat.c
  SanitizerCommon-lsan-x86_64-Linux :: printf-ldbl.c
  SanitizerCommon-lsan-x86_64-Linux :: scanf-ldbl.c
  SanitizerCommon-lsan-x86_64-Linux :: strcasestr.c
  SanitizerCommon-lsan-x86_64-Linux :: strcspn.c
  SanitizerCommon-lsan-x86_64-Linux :: strnlen.c
  SanitizerCommon-lsan-x86_64-Linux :: strpbrk.c
  SanitizerCommon-lsan-x86_64-Linux :: strspn.c
  SanitizerCommon-lsan-x86_64-Linux :: strstr.c
  SanitizerCommon-lsan-x86_64-Linux :: wcrtomb.c
  SanitizerCommon-lsan-x86_64-Linux :: wctomb.c
Testing Time: 653.19s
  Unsupported      :  496
  Passed           : 1169
  Expectedly Failed:   32
  Failed           :   81

to

Failed Tests (1):
  SanitizerCommon-asan-x86_64-Linux :: Linux/getpwnam_r_invalid_user.cpp
Testing Time: 22.38s
  Unsupported      :  496
  Passed           : 1249
  Expectedly Failed:   32
  Failed           :    1
vitalybuka accepted this revision.Dec 30 2020, 12:45 PM
This revision is now accepted and ready to land.Dec 30 2020, 12:45 PM

In fact after your rG9a5261efd75530d10ce7a346e8127ba1f00db085 it is no longer a problem. Without this patch it only shows:

Failed Tests (3):
  SanitizerCommon-Unit :: ./Sanitizer-i386-Test/SanitizerLinux.ThreadDescriptorSize
  SanitizerCommon-Unit :: ./Sanitizer-x86_64-Test/SanitizerLinux.ThreadDescriptorSize
  SanitizerCommon-asan-x86_64-Linux :: Linux/getpwnam_r_invalid_user.cpp

I have no idea how is it related. Also I am curious when the testcase can detect the pthread size why the sanitizer does not detect it at runtime? Sorry for not reading all the code.