[PATCH] D20048: [sanitizer] On OS X, exit the forked process gracefully when login_tty fails

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Sat May 7 07:41:17 PDT 2016


kubabrecka created this revision.
kubabrecka added reviewers: dvyukov, glider, samsonov, kcc, aizatsky.
kubabrecka added subscribers: llvm-commits, zaks.anna, dcoughlin.
kubabrecka added a project: Sanitizers.
Herald added a subscriber: kubabrecka.

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.).

http://reviews.llvm.org/D20048

Files:
  lib/sanitizer_common/sanitizer_mac.cc

Index: lib/sanitizer_common/sanitizer_mac.cc
===================================================================
--- lib/sanitizer_common/sanitizer_mac.cc
+++ lib/sanitizer_common/sanitizer_mac.cc
@@ -195,7 +195,11 @@
   }
   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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20048.56496.patch
Type: text/x-patch
Size: 545 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160507/b323a004/attachment-0001.bin>


More information about the llvm-commits mailing list