[PATCH] tsan: do not deadlock on fork

Dmitry Vyukov dvyukov at google.com
Fri Jan 24 03:42:08 PST 2014


Hi kcc,

Currently correct programs can deadlock after fork, because atomic operations and async-signal-safe calls are not async-signal-safe under tsan.
With this change:
- if a single-threaded program forks, the child continues running with verification enabled (the tsan background thread is recreated as well)
- if a multi-threaded program forks, then the child runs with verification disabled (memory accesses, atomic operations and interceptors are disabled); it's expected that it will exec soon anyway
- if the child tries to create more threads after multi-threaded fork, the program aborts with error message
- die_after_fork flag is added that allows to continue running, but all bets are off



http://llvm-reviews.chandlerc.com/D2614

Files:
  lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
  lib/tsan/rtl/tsan_interface_atomic.cc
  lib/tsan/rtl/tsan_flags.cc
  lib/tsan/rtl/tsan_flags.h
  lib/tsan/rtl/tsan_rtl.cc
  lib/tsan/rtl/tsan_rtl.h
  lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc
  lib/tsan/rtl/tsan_interceptors.cc
  lib/tsan/rtl/tsan_rtl_thread.cc
  lib/tsan/tests/unit/tsan_flags_test.cc
  lib/tsan/lit_tests/fork_multithreaded3.cc
  lib/tsan/lit_tests/fork_multithreaded.cc
  lib/tsan/lit_tests/fork_multithreaded2.cc
  lib/tsan/lit_tests/fork_deadlock.cc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2614.1.patch
Type: text/x-patch
Size: 21117 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140124/b7745f45/attachment.bin>


More information about the llvm-commits mailing list