[compiler-rt] r185631 - [ASan] Close stderr before launching atos in asan_symbolize.py

Alexander Potapenko glider at google.com
Thu Jul 4 07:21:49 PDT 2013


Author: glider
Date: Thu Jul  4 09:21:49 2013
New Revision: 185631

URL: http://llvm.org/viewvc/llvm-project?rev=185631&view=rev
Log:
[ASan] Close stderr before launching atos in asan_symbolize.py

Modified:
    compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py

Modified: compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py?rev=185631&r1=185630&r2=185631&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py (original)
+++ compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py Thu Jul  4 09:21:49 2013
@@ -142,10 +142,13 @@ class UnbufferedLineConverter(object):
   Wrap a child process that responds to each line of input with one line of
   output.  Uses pty to trick the child into providing unbuffered output.
   """
-  def __init__(self, args):
+  def __init__(self, args, close_stderr=False):
     pid, fd = pty.fork()
     if pid == 0:
-      # We're the child.  Transfer control to command.
+      # We're the child. Transfer control to command.
+      if close_stderr:
+        dev_null = os.open('/dev/null', 0)
+        os.dup2(dev_null, 2)
       os.execvp(args[0], args)
     else:
       # Disable echoing.
@@ -179,7 +182,7 @@ class DarwinSymbolizer(Symbolizer):
     if DEBUG:
       print 'atos -o %s -arch %s' % (self.binary, self.arch)
     cmdline = ['atos', '-o', self.binary, '-arch', self.arch]
-    self.atos = UnbufferedLineConverter(cmdline)
+    self.atos = UnbufferedLineConverter(cmdline, close_stderr=True)
 
   def symbolize(self, addr, binary, offset):
     """Overrides Symbolizer.symbolize."""





More information about the llvm-commits mailing list