[sanitizer] Support running without fd 0,1,2.
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Wed, 19 Dec 2018 23:45:17 +0000 (23:45 +0000)
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Wed, 19 Dec 2018 23:45:17 +0000 (23:45 +0000)
commitf762a9f8f0b95db3ec2e7ff9e17e8663df64b579
tree0b92f075ed924b4b666708cedb7798c30933c491
parentb68cb5498b7db48c236ea5b9c234fbe2e47f1652
[sanitizer] Support running without fd 0,1,2.

Summary:
Support running with no open file descriptors (as may happen to
"init" process on linux).
* Remove a check that writing to stderr succeeds.
* When opening a file (ex. for log_path option), dup the new fd out of
[0, 2] range to avoid confusing the program.

Reviewers: pcc, vitalybuka

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 349699
compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
compiler-rt/lib/sanitizer_common/sanitizer_netbsd.cc
compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
compiler-rt/lib/sanitizer_common/sanitizer_posix.h
compiler-rt/lib/sanitizer_common/sanitizer_rtems.cc
compiler-rt/lib/sanitizer_common/sanitizer_solaris.cc
compiler-rt/test/asan/TestCases/Posix/no-fd.cc [new file with mode: 0644]