<div dir="ltr">The test with -Wl,-as-needed breaks in several places. I have removed that in r245417. Could you look into what is happening? Happy to provide more instructions for a reproduction.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 18, 2015 at 10:36 PM, Evgeniy Stepanov via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: eugenis<br>
Date: Tue Aug 18 15:36:48 2015<br>
New Revision: 245345<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=245345&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=245345&view=rev</a><br>
Log:<br>
[msan] Intercept openpty and forkpty.<br>
<br>
Added:<br>
    compiler-rt/trunk/test/msan/Linux/forkpty.cc<br>
Modified:<br>
    compiler-rt/trunk/lib/msan/msan_interceptors.cc<br>
<br>
Modified: compiler-rt/trunk/lib/msan/msan_interceptors.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=245345&r1=245344&r2=245345&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=245345&r1=245344&r2=245345&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)<br>
+++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Tue Aug 18 15:36:48 2015<br>
@@ -1335,6 +1335,28 @@ INTERCEPTOR(int, fork, void) {<br>
   return pid;<br>
 }<br>
<br>
+INTERCEPTOR(int, openpty, int *amaster, int *aslave, char *name,<br>
+            const void *termp, const void *winp) {<br>
+  ENSURE_MSAN_INITED();<br>
+  InterceptorScope interceptor_scope;<br>
+  int res = REAL(openpty)(amaster, aslave, name, termp, winp);<br>
+  if (!res) {<br>
+    __msan_unpoison(amaster, sizeof(*amaster));<br>
+    __msan_unpoison(aslave, sizeof(*aslave));<br>
+  }<br>
+  return res;<br>
+}<br>
+<br>
+INTERCEPTOR(int, forkpty, int *amaster, char *name, const void *termp,<br>
+            const void *winp) {<br>
+  ENSURE_MSAN_INITED();<br>
+  InterceptorScope interceptor_scope;<br>
+  int res = REAL(forkpty)(amaster, name, termp, winp);<br>
+  if (res != -1)<br>
+    __msan_unpoison(amaster, sizeof(*amaster));<br>
+  return res;<br>
+}<br>
+<br>
 struct MSanInterceptorContext {<br>
   bool in_interceptor_scope;<br>
 };<br>
@@ -1599,6 +1621,8 @@ void InitializeInterceptors() {<br>
   INTERCEPT_FUNCTION(__cxa_atexit);<br>
   INTERCEPT_FUNCTION(shmat);<br>
   INTERCEPT_FUNCTION(fork);<br>
+  INTERCEPT_FUNCTION(openpty);<br>
+  INTERCEPT_FUNCTION(forkpty);<br>
<br>
   inited = 1;<br>
 }<br>
<br>
Added: compiler-rt/trunk/test/msan/Linux/forkpty.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/msan/Linux/forkpty.cc?rev=245345&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/msan/Linux/forkpty.cc?rev=245345&view=auto</a><br>
==============================================================================<br>
--- compiler-rt/trunk/test/msan/Linux/forkpty.cc (added)<br>
+++ compiler-rt/trunk/test/msan/Linux/forkpty.cc Tue Aug 18 15:36:48 2015<br>
@@ -0,0 +1,19 @@<br>
+// RUN: %clangxx_msan -O0 -g %s -lutil -o %t && %run %t<br>
+// RUN: %clangxx_msan -O0 -g %s -Wl,-as-needed -lutil -o %t && %run %t<br>
+#include <assert.h><br>
+#include <pty.h><br>
+<br>
+#include <sanitizer/msan_interface.h><br>
+<br>
+int<br>
+main (int argc, char** argv)<br>
+{<br>
+  int master, slave;<br>
+  openpty(&master, &slave, NULL, NULL, NULL);<br>
+  assert(__msan_test_shadow(&master, sizeof(master)) == -1);<br>
+  assert(__msan_test_shadow(&slave, sizeof(slave)) == -1);<br>
+<br>
+  int master2;<br>
+  forkpty(&master2, NULL, NULL, NULL);<br>
+  assert(__msan_test_shadow(&master2, sizeof(master2)) == -1);<br>
+}<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>