llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[TSan RTL] hang in symbolizer code

Open llvmbot opened this issue 12 years ago • 6 comments

Bugzilla Link 18379
Resolution FIXED
Resolved on Mar 24, 2014 20:40
Version unspecified
OS Linux
Reporter LLVM Bugzilla Contributor
CC @KernelAddress,@kcc

Extended Description

Running a program that reports a lot of TSAN errors, I ended up with one of my threads stuck in the following stack:

(gdb) bt #​0 0x00007fab3cb07319 in syscall () from /lib64/libc.so.6 #​1 0x00007fab3febaa61 in __sanitizer::internal_read(int, void*, unsigned long) () #​2 0x00007fab3fef3fe8 in __tsan::SymbolizeCodeAddr2Line(unsigned long) () #​3 0x00007fab3feefbbd in __tsan::SymbolizeStack(__tsan::StackTrace const&) () #​4 0x00007fab3fef1aa2 in __tsan::PrintCurrentStack(__tsan::ThreadState*, unsigned long) () #​5 0x00007fab3feeee88 in __tsan::MutexUnlock(__tsan::ThreadState*, unsigned long, unsigned long) ()

If I look for hung addr2line processes, I see:

(gdb) bt #​0 0x0000003c982db630 in __read_nocancel () from /lib64/libc.so.6 #​1 0x0000003c98271fa8 in _IO_new_file_underflow () from /lib64/libc.so.6 #​2 0x0000003c98273aae in _IO_default_uflow_internal () from /lib64/libc.so.6 #​3 0x0000003c9826818a in _IO_getline_info_internal () from /lib64/libc.so.6 #​4 0x0000003c98266fe9 in fgets () from /lib64/libc.so.6 #​5 0x00000000004020e9 in ?? () #​6 0x0000003c9821ecdd in __libc_start_main () from /lib64/libc.so.6

which implies that, for some reason, the Addr2Line code is sending some kind of partial input into the addr2line binary, and then expecting a response. Addr2line is still expecting the input, and we end up hanging forever.

This is with llvm/clang 3.3.

llvmbot avatar Jan 04 '14 07:01 llvmbot

The issue isn't quite the same using the llvm symbolizer, but I get a segfault there. I reported it on the Google Code project here: https://code.google.com/p/thread-sanitizer/issues/detail?id=55

llvmbot avatar Mar 25 '14 03:03 llvmbot

I got rid of __tsan::SymbolizeCodeAddr2Line, (discouraged) addr2line symbolization now works much like the llvm-symbolizer-based solution we test. Please reopen if you still observe similar problems.

llvmbot avatar Feb 12 '14 11:02 llvmbot

Good point.

Todd, is there a way we can reproduce this problem? Also, please check if using llvm-symbolizer fixes this problem for you: specify TSAN_OPTIONS=external_symbolizer_path=/path/to/llvm-symbolizer in your env, or just make sure that llvm-symbolizer is in your $PATH.

There can indeed be problem with addr2line communication: just calling internal_read(addr2line_fd, ...) is not enough - the response from addr2line may not be received atomically, the correct way to do this is to call internal_read(addr2line_fd, ...) repeatedly until we see the end of response (line break). We should better get rid of the code in tsan_symbolize_addr2line_linux by:

  1. claiming the user must provide the path llvm-symbolizer (expicitly or in $PATH) and crashing the program otherwise.
  2. sharing inter-process communication code with the one in generic sanitizer symbolizer.
  3. do nothing until we have in-process symbolizer on Linux.

llvmbot avatar Jan 17 '14 11:01 llvmbot

But we need online symbolization for tsan, so it's not "as in other tools".

KernelAddress avatar Jan 17 '14 10:01 KernelAddress

Dmitry, what do you think of dropping support for addr2line symbolization from TSan? It is pretty somewhat undertested now. The users will have to use llvm-symbolizer in the same way as in another sanitizers.

llvmbot avatar Jan 17 '14 10:01 llvmbot

please file tsan-rtl bugs here: https://code.google.com/p/thread-sanitizer/ I'd suspect that the solution for this problem is not to use addr2line symbolizer, but to use llvm-symbolizer instead. https://code.google.com/p/address-sanitizer/wiki/CallStack

Alexey, Dmitry, please see that we have proper documentation of symbolizers across asan/tsan/msan

kcc avatar Jan 07 '14 12:01 kcc