[compiler-rt] r221896 - [ASan] Add process basename to log name and error message to simplify analysis of sanitized systems logs.
Yury Gribov
y.gribov at samsung.com
Thu Nov 13 10:44:37 PST 2014
On 11/13/2014 08:21 PM, David Blaikie wrote:
> On Thu, Nov 13, 2014 at 8:01 AM, Yury Gribov <y.gribov at samsung.com> wrote:
>
>> Author: ygribov
>> Date: Thu Nov 13 10:01:23 2014
>> New Revision: 221896
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=221896&view=rev
>> Log:
>> [ASan] Add process basename to log name and error message to simplify
>> analysis of sanitized systems logs.
>>
>> Reviewed at http://reviews.llvm.org/D5724
>>
>> Modified:
>> compiler-rt/trunk/lib/asan/asan_report.cc
>> compiler-rt/trunk/lib/msan/msan_interceptors.cc
>> compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc
>> compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
>> compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc
>> compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
>> compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.h
>> compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
>> compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc
>> compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc
>>
>> compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
>> compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
>> compiler-rt/trunk/test/asan/TestCases/log-path_test.cc
>> compiler-rt/trunk/test/asan/TestCases/log_path_fork_test.cc.disabled
>>
>> Modified: compiler-rt/trunk/lib/asan/asan_report.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_report.cc?rev=221896&r1=221895&r2=221896&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/asan/asan_report.cc (original)
>> +++ compiler-rt/trunk/lib/asan/asan_report.cc Thu Nov 13 10:01:23 2014
>> @@ -53,7 +53,7 @@ void AppendToErrorMessageBuffer(const ch
>> buffer, remaining);
>> error_message_buffer[error_message_buffer_size - 1] = '\0';
>> // FIXME: reallocate the buffer instead of truncating the message.
>> - error_message_buffer_pos += remaining > length ? length : remaining;
>> + error_message_buffer_pos += Min(remaining, length);
>> }
>> }
>>
>>
>> Modified: compiler-rt/trunk/lib/msan/msan_interceptors.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=221896&r1=221895&r2=221896&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
>> +++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Thu Nov 13 10:01:23
>> 2014
>> @@ -803,7 +803,7 @@ INTERCEPTOR(SSIZE_T, recvfrom, int fd, v
>> __msan_unpoison(buf, res);
>> if (srcaddr) {
>> SIZE_T sz = *addrlen;
>> - __msan_unpoison(srcaddr, (sz < srcaddr_sz) ? sz : srcaddr_sz);
>> + __msan_unpoison(srcaddr, Min(sz, srcaddr_sz));
>> }
>> }
>> return res;
>>
>> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc?rev=221896&r1=221895&r2=221896&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc (original)
>> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc Thu Nov 13
>> 10:01:23 2014
>> @@ -160,6 +160,8 @@ const char *StripModuleName(const char *
>> return 0;
>> if (const char *slash_pos = internal_strrchr(module, '/'))
>> return slash_pos + 1;
>> + else if (const char *backslash_pos = internal_strrchr(module, '\\'))
>> + return backslash_pos + 1;
>> return module;
>> }
>>
>> @@ -225,6 +227,24 @@ void DecreaseTotalMmap(uptr size) {
>> atomic_fetch_sub(&g_total_mmaped, size, memory_order_relaxed);
>> }
>>
>> +static BlockingMutex binary_name_cache_lock(LINKER_INITIALIZED);
>>
>
> This breaks a clang build of compiler-rt:
Ok, I thought compiler-rt with standard setup is built with clang, silly me.
> llvm/src/projects/compiler-rt/lib/sanitizer_common/sanitizer_common.cc:230:22:
> error: declaration requires a global constructor
> [-Werror,-Wglobal-constructors]
> static BlockingMutex binary_name_cache_lock(LINKER_INITIALIZED);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> While LINKER_INITIALIZED might sound nice, it seems it doesn't actually do
> what it says on the tin - BlockingMutex still has a user defined (albeit
> no-op in an optimized build) ctor, which produces a global ctor to run it,
> etc...
That's interesting, we have tons of places which use this pattern but
only this one fails. I'll need some time to repro here. Does
s/(LINKER_INITIALIZED)// solve the problem by chance? What would be the
right way to proceed now:
* apply temp fix
* revert my patch
* wait for sanitizer team comments on this (LINKER_INITIALIZED is
heavily used in ASan sources)
?
-Y
More information about the llvm-commits
mailing list