[compiler-rt] Replace forkpty with posix_spawn
authorKuba Mracek <mracek@apple.com>
Sun, 11 Feb 2018 19:23:42 +0000 (19:23 +0000)
committerKuba Mracek <mracek@apple.com>
Sun, 11 Feb 2018 19:23:42 +0000 (19:23 +0000)
commit3ecf9dcaf4877994903d15694c87778cc2fe94cb
tree96500fdbaca3dab9029cae606d6c9705be1a5cd4
parent3a354152dd772ced97372a9c6e5706653465a409
[compiler-rt] Replace forkpty with posix_spawn

On Darwin, we currently use forkpty to communicate with the "atos" symbolizer. There are several problems that fork or forkpty has, e.g. that after fork, interceptors are still active and this sometimes causes crashes or hangs. This is especially problematic for TSan, which uses interceptors for OS-provided locks and mutexes, and even Libc functions use those.

This patch replaces forkpty with posix_spawn. Since posix_spawn doesn't fork (at least on Darwin), the interceptors are not a problem. Additionally, this also fixes a latent threading problem with ptsname (it's unsafe to use this function in multithreaded programs). Yet another benefit is that we'll handle post-fork failures (e.g. sandbox disallows "exec") gracefully now.

Differential Revision: https://reviews.llvm.org/D40032

llvm-svn: 324846
compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
compiler-rt/lib/sanitizer_common/sanitizer_posix.h
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cc
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc