<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 13, 2014 at 10:44 AM, Yury Gribov <span dir="ltr"><<a href="mailto:y.gribov@samsung.com" target="_blank">y.gribov@samsung.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 11/13/2014 08:21 PM, David Blaikie wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Thu, Nov 13, 2014 at 8:01 AM, Yury Gribov <<a href="mailto:y.gribov@samsung.com" target="_blank">y.gribov@samsung.com</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: ygribov<br>
Date: Thu Nov 13 10:01:23 2014<br>
New Revision: 221896<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=221896&view=rev" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project?rev=221896&view=rev</a><br>
Log:<br>
[ASan] Add process basename to log name and error message to simplify<br>
analysis of sanitized systems logs.<br>
<br>
Reviewed at <a href="http://reviews.llvm.org/D5724" target="_blank">http://reviews.llvm.org/D5724</a><br>
<br>
Modified:<br>
compiler-rt/trunk/lib/asan/<u></u>asan_report.cc<br>
compiler-rt/trunk/lib/msan/<u></u>msan_interceptors.cc<br>
compiler-rt/trunk/lib/<u></u>sanitizer_common/sanitizer_<u></u>common.cc<br>
compiler-rt/trunk/lib/<u></u>sanitizer_common/sanitizer_<u></u>common.h<br>
compiler-rt/trunk/lib/<u></u>sanitizer_common/sanitizer_<u></u>flags.cc<br>
compiler-rt/trunk/lib/<u></u>sanitizer_common/sanitizer_<u></u>linux.cc<br>
compiler-rt/trunk/lib/<u></u>sanitizer_common/sanitizer_<u></u>linux.h<br>
compiler-rt/trunk/lib/<u></u>sanitizer_common/sanitizer_<u></u>mac.cc<br>
compiler-rt/trunk/lib/<u></u>sanitizer_common/sanitizer_<u></u>posix.cc<br>
compiler-rt/trunk/lib/<u></u>sanitizer_common/sanitizer_<u></u>printf.cc<br>
<br>
compiler-rt/trunk/lib/<u></u>sanitizer_common/sanitizer_<u></u>symbolizer_posix_libcdep.cc<br>
compiler-rt/trunk/lib/<u></u>sanitizer_common/sanitizer_<u></u>win.cc<br>
compiler-rt/trunk/test/asan/<u></u>TestCases/log-path_test.cc<br>
compiler-rt/trunk/test/asan/<u></u>TestCases/log_path_fork_test.<u></u>cc.disabled<br>
<br>
Modified: compiler-rt/trunk/lib/asan/<u></u>asan_report.cc<br>
URL:<br>
<a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_report.cc?rev=221896&r1=221895&r2=221896&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/compiler-rt/trunk/lib/<u></u>asan/asan_report.cc?rev=<u></u>221896&r1=221895&r2=221896&<u></u>view=diff</a><br>
<br>
==============================<u></u>==============================<u></u>==================<br>
--- compiler-rt/trunk/lib/asan/<u></u>asan_report.cc (original)<br>
+++ compiler-rt/trunk/lib/asan/<u></u>asan_report.cc Thu Nov 13 10:01:23 2014<br>
@@ -53,7 +53,7 @@ void AppendToErrorMessageBuffer(<u></u>const ch<br>
buffer, remaining);<br>
error_message_buffer[error_<u></u>message_buffer_size - 1] = '\0';<br>
// FIXME: reallocate the buffer instead of truncating the message.<br>
- error_message_buffer_pos += remaining > length ? length : remaining;<br>
+ error_message_buffer_pos += Min(remaining, length);<br>
}<br>
}<br>
<br>
<br>
Modified: compiler-rt/trunk/lib/msan/<u></u>msan_interceptors.cc<br>
URL:<br>
<a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=221896&r1=221895&r2=221896&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/compiler-rt/trunk/lib/<u></u>msan/msan_interceptors.cc?rev=<u></u>221896&r1=221895&r2=221896&<u></u>view=diff</a><br>
<br>
==============================<u></u>==============================<u></u>==================<br>
--- compiler-rt/trunk/lib/msan/<u></u>msan_interceptors.cc (original)<br>
+++ compiler-rt/trunk/lib/msan/<u></u>msan_interceptors.cc Thu Nov 13 10:01:23<br>
2014<br>
@@ -803,7 +803,7 @@ INTERCEPTOR(SSIZE_T, recvfrom, int fd, v<br>
__msan_unpoison(buf, res);<br>
if (srcaddr) {<br>
SIZE_T sz = *addrlen;<br>
- __msan_unpoison(srcaddr, (sz < srcaddr_sz) ? sz : srcaddr_sz);<br>
+ __msan_unpoison(srcaddr, Min(sz, srcaddr_sz));<br>
}<br>
}<br>
return res;<br>
<br>
Modified: compiler-rt/trunk/lib/<u></u>sanitizer_common/sanitizer_<u></u>common.cc<br>
URL:<br>
<a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc?rev=221896&r1=221895&r2=221896&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/compiler-rt/trunk/lib/<u></u>sanitizer_common/sanitizer_<u></u>common.cc?rev=221896&r1=<u></u>221895&r2=221896&view=diff</a><br>
<br>
==============================<u></u>==============================<u></u>==================<br>
--- compiler-rt/trunk/lib/<u></u>sanitizer_common/sanitizer_<u></u>common.cc (original)<br>
+++ compiler-rt/trunk/lib/<u></u>sanitizer_common/sanitizer_<u></u>common.cc Thu Nov 13<br>
10:01:23 2014<br>
@@ -160,6 +160,8 @@ const char *StripModuleName(const char *<br>
return 0;<br>
if (const char *slash_pos = internal_strrchr(module, '/'))<br>
return slash_pos + 1;<br>
+ else if (const char *backslash_pos = internal_strrchr(module, '\\'))<br>
+ return backslash_pos + 1;<br>
return module;<br>
}<br>
<br>
@@ -225,6 +227,24 @@ void DecreaseTotalMmap(uptr size) {<br>
atomic_fetch_sub(&g_total_<u></u>mmaped, size, memory_order_relaxed);<br>
}<br>
<br>
+static BlockingMutex binary_name_cache_lock(LINKER_<u></u>INITIALIZED);<br>
<br>
</blockquote>
<br>
This breaks a clang build of compiler-rt:<br>
</blockquote>
<br></div></div>
Ok, I thought compiler-rt with standard setup is built with clang, silly me.</blockquote><div><br></div><div>You're right, it should be - I think it is on my system. Not sure what might be going wrong here for you... </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
llvm/src/projects/compiler-rt/<u></u>lib/sanitizer_common/<u></u>sanitizer_common.cc:230:22:<br>
error: declaration requires a global constructor<br>
[-Werror,-Wglobal-<u></u>constructors]<br>
static BlockingMutex binary_name_cache_lock(LINKER_<u></u>INITIALIZED);<br>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<u></u>~~~~~~~~~~~~<br>
<br>
While LINKER_INITIALIZED might sound nice, it seems it doesn't actually do<br>
what it says on the tin - BlockingMutex still has a user defined (albeit<br>
no-op in an optimized build) ctor, which produces a global ctor to run it,<br>
etc...<br>
</blockquote>
<br></span>
That's interesting, we have tons of places which use this pattern but only this one fails.</blockquote><div><br>Only sanitizer_common and tsan has the global-constructors warning on. And in sanitizer_common I don't see any other instances of this.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> I'll need some time to repro here. Does s/(LINKER_INITIALIZED)// solve the problem by chance? </blockquote><div><br>Nope - still a global constructor due to the user defined <br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">What would be the right way to proceed now:<br>
* apply temp fix<br>
* revert my patch<br></blockquote><div><br>I expect this is the right answer ^ in the short term. Revert and discuss/figure out the right fix.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
* wait for sanitizer team comments on this (LINKER_INITIALIZED is heavily used in ASan sources)<br>
?<span class="HOEnZb"><font color="#888888"><br>
<br>
-Y<br>
</font></span></blockquote></div><br></div></div>