[compiler-rt] r221896 - [ASan] Add process basename to log name and error message to simplify analysis of sanitized systems logs.

David Blaikie dblaikie at gmail.com
Thu Nov 13 11:18:44 PST 2014


On Thu, Nov 13, 2014 at 10:44 AM, Yury Gribov <y.gribov at samsung.com> wrote:

> 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.


You're right, it should be - I think it is on my system. Not sure what
might be going wrong here for you...


>
>
>  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.


Only sanitizer_common and tsan has the global-constructors warning on. And
in sanitizer_common I don't see any other instances of this.


> I'll need some time to repro here. Does s/(LINKER_INITIALIZED)// solve the
> problem by chance?


Nope - still a global constructor due to the user defined


> What would be the right way to proceed now:
> * apply temp fix
> * revert my patch
>

I expect this is the right answer ^ in the short term. Revert and
discuss/figure out the right fix.


> * wait for sanitizer team comments on this (LINKER_INITIALIZED is heavily
> used in ASan sources)
> ?
>
> -Y
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141113/9ae08f15/attachment.html>


More information about the llvm-commits mailing list