<div dir="ltr">On Mon, Apr 8, 2013 at 2:03 AM, Evgeniy Stepanov <span dir="ltr"><<a href="mailto:eugeni.stepanov@gmail.com" target="_blank" class="cremed">eugeni.stepanov@gmail.com</a>></span> wrote:<br><div class="gmail_extra">
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: eugenis<br>
Date: Mon Apr  8 04:03:00 2013<br>
New Revision: 179012<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=179012&view=rev" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project?rev=179012&view=rev</a><br>
Log:<br>
[msan] Intercept glob().<br>
<br>
Modified:<br>
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc<br>
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h<br>
    compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc<br>
    compiler-rt/trunk/lib/tsan/rtl/tsan_stat.h<br></blockquote><div><br></div><div style>Err, no tests at all? This isn't acceptable. Please commit code like this with proper testing. There is at least one obvious bug in the code, and I don't know how many others or how to write unittests for it as you've not laid out the groundwork in this commit...</div>
<div style><br></div><div style>I've reverted this commit in r179054, unbreaking roughly all users of ASan.</div><div style><br></div><div style>See the comments below for the bug we spotted, I've no idea if there are more lurking here:</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc?rev=179012&r1=179011&r2=179012&view=diff" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc?rev=179012&r1=179011&r2=179012&view=diff</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)<br>
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Mon Apr  8 04:03:00 2013<br>
@@ -549,6 +549,53 @@ INTERCEPTOR(int, setitimer, int which, c<br>
 #endif<br>
<br>
<br>
+#if SANITIZER_INTERCEPT_GLOB<br>
+struct sanitizer_glob_t {<br>
+  SIZE_T gl_pathc;<br>
+  char **gl_pathv;<br>
+};<br>
+<br>
+static void unpoison_glob_t(void *ctx, sanitizer_glob_t *pglob) {<br>
+  COMMON_INTERCEPTOR_WRITE_RANGE(ctx, pglob, sizeof(*pglob));<br>
+  // +1 for NULL pointer at the end.<br>
+  COMMON_INTERCEPTOR_WRITE_RANGE(<br>
+      ctx, pglob->gl_pathv,<br>
+      (sizeof(pglob->gl_pathc) + 1) * sizeof(*pglob->gl_pathv));<br></blockquote><div><br></div><div style>I don't think you want 'sizeof(pglob->gl_pathc) + 1', I think you just want 'pglob->gl_pathc + 1' as that is the count of things, and we're about to scale it by the size of the things...</div>
</div></div></div>