[compiler-rt] r269289 - [sanitizer] On OS X, exit the forked process gracefully when login_tty fails

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Thu May 12 05:53:43 PDT 2016


Author: kuba.brecka
Date: Thu May 12 07:53:43 2016
New Revision: 269289

URL: http://llvm.org/viewvc/llvm-project?rev=269289&view=rev
Log:
[sanitizer] On OS X, exit the forked process gracefully when login_tty fails

We're using forkpty to spawn the atos symbolizer. In some cases, login_tty (part of forkpty) can fail due to security measures (sandboxing). In this case, we should exit with a status code instead of completely crashing the spawned process. Even processing a failed CHECK() is problematic here, because we're post-fork and pre-exec where a lot of things don't work (for multithreaded processes, for OS X GUI apps, etc.).

Differential Revision: http://reviews.llvm.org/D20048


Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc?rev=269289&r1=269288&r2=269289&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc Thu May 12 07:53:43 2016
@@ -195,7 +195,11 @@ int internal_forkpty(int *amaster) {
   }
   if (pid == 0) {
     close(master);
-    CHECK_EQ(login_tty(slave), 0);
+    if (login_tty(slave) != 0) {
+      // We already forked, there's not much we can do.  Let's quit.
+      Report("login_tty failed (errno %d)\n", errno);
+      internal__exit(1);
+    }
   } else {
     *amaster = master;
     close(slave);




More information about the llvm-commits mailing list