[compiler-rt] r192979 - [asan] reduce the size of AsanThreadContext by storing the stack trace in the stack depot
Alexander Potapenko
glider at google.com
Fri Oct 18 09:39:14 PDT 2013
GCD tests are failing when trying to print the thread creation stack.
Perhaps you're dereferencing NULL somewhere (not sure we're keeping
the creation stack for GCD workers):
[ OK ] AddressSanitizerMac.CFAllocatorMallocDoubleFree (746 ms)
[ RUN ] AddressSanitizerMac.GCDDispatchAsync
/Users/buildbot/src/llvm-buildbot/slave/mac10.8-cmake/build/llvm/projects/compiler-rt/lib/asan/tests/asan_mac_test.cc:92:
Failure
Death test: TestGCDDispatchAsync()
Result: died but not with expected error.
Expected: Shadow byte legend
Actual msg:
[ DEATH ] =================================================================
[ DEATH ] ==44993==ERROR: AddressSanitizer: heap-buffer-overflow on
address 0x61900002fc80 at pc 0x10eacfd2f bp 0x112528560 sp 0x112528558
[ DEATH ] WRITE of size 1 at 0x61900002fc80 thread T1
[ DEATH ] #0 0x10eacfd2e
(/Users/buildbot/src/llvm-buildbot/slave/mac10.8-cmake/build/./llvm_build64/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test+0x100204d2e)
[ DEATH ] #1 0x10ead0507
(/Users/buildbot/src/llvm-buildbot/slave/mac10.8-cmake/build/./llvm_build64/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test+0x100205507)
[ DEATH ] #2 0x10ecbfad3
(/Users/buildbot/src/llvm-buildbot/slave/mac10.8-cmake/build/llvm_build64/lib/clang/3.4/lib/darwin/libclang_rt.asan_osx_dynamic.dylib+0x1aad3)
[ DEATH ] #3 0x7fff8f0f0f00 (/usr/lib/system/libdispatch.dylib+0x5f00)
[ DEATH ] #4 0x7fff8f0ed0b5 (/usr/lib/system/libdispatch.dylib+0x20b5)
[ DEATH ] #5 0x7fff8f0ee1f9 (/usr/lib/system/libdispatch.dylib+0x31f9)
[ DEATH ] #6 0x7fff94a3bcda (/usr/lib/system/libsystem_c.dylib+0x16cda)
[ DEATH ] #7 0x7fff94a26190 (/usr/lib/system/libsystem_c.dylib+0x1190)
[ DEATH ] 0x61900002fc80 is located 0 bytes to the right of
1024-byte region [0x61900002f880,0x61900002fc80)
[ DEATH ] allocated by thread T1 here:
[ DEATH ] #0 0x10ecc04c5
(/Users/buildbot/src/llvm-buildbot/slave/mac10.8-cmake/build/llvm_build64/lib/clang/3.4/lib/darwin/libclang_rt.asan_osx_dynamic.dylib+0x1b4c5)
[ DEATH ] #1 0x10ead04d8
(/Users/buildbot/src/llvm-buildbot/slave/mac10.8-cmake/build/./llvm_build64/projects/compiler-rt/lib/asan/tests/Asan-x86_64-Test+0x1002054d8)
[ DEATH ] #2 0x10ecbfad3
(/Users/buildbot/src/llvm-buildbot/slave/mac10.8-cmake/build/llvm_build64/lib/clang/3.4/lib/darwin/libclang_rt.asan_osx_dynamic.dylib+0x1aad3)
[ DEATH ] #3 0x7fff8f0f0f00 (/usr/lib/system/libdispatch.dylib+0x5f00)
[ DEATH ] #4 0x7fff8f0ed0b5 (/usr/lib/system/libdispatch.dylib+0x20b5)
[ DEATH ] #5 0x7fff8f0ee1f9 (/usr/lib/system/libdispatch.dylib+0x31f9)
[ DEATH ] #6 0x7fff94a3bcda (/usr/lib/system/libsystem_c.dylib+0x16cda)
[ DEATH ] #7 0x7fff94a26190 (/usr/lib/system/libsystem_c.dylib+0x1190)
[ DEATH ] Thread T1 created by T0 here:
[ DEATH ] ASAN:SIGSEGV
[ DEATH ] ==44993==AddressSanitizer: while reporting a bug found
another one.Ignoring.
[ DEATH ]
[ FAILED ] AddressSanitizerMac.GCDDispatchAsync (743 ms)
On Fri, Oct 18, 2013 at 8:37 PM, Alexander Potapenko <glider at google.com> wrote:
> Either 192979 or 192980 broke the Mac build.
>
> On Fri, Oct 18, 2013 at 6:50 PM, Kostya Serebryany <kcc at google.com> wrote:
>> Author: kcc
>> Date: Fri Oct 18 09:50:44 2013
>> New Revision: 192979
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=192979&view=rev
>> Log:
>> [asan] reduce the size of AsanThreadContext by storing the stack trace in the stack depot
>>
>> Modified:
>> compiler-rt/trunk/lib/asan/asan_report.cc
>> compiler-rt/trunk/lib/asan/asan_stack.cc
>> compiler-rt/trunk/lib/asan/asan_stack.h
>> compiler-rt/trunk/lib/asan/asan_thread.cc
>> compiler-rt/trunk/lib/asan/asan_thread.h
>>
>> 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=192979&r1=192978&r2=192979&view=diff
>> ==============================================================================
>> --- compiler-rt/trunk/lib/asan/asan_report.cc (original)
>> +++ compiler-rt/trunk/lib/asan/asan_report.cc Fri Oct 18 09:50:44 2013
>> @@ -20,6 +20,7 @@
>> #include "sanitizer_common/sanitizer_common.h"
>> #include "sanitizer_common/sanitizer_flags.h"
>> #include "sanitizer_common/sanitizer_report_decorator.h"
>> +#include "sanitizer_common/sanitizer_stackdepot.h"
>> #include "sanitizer_common/sanitizer_symbolizer.h"
>>
>> namespace __asan {
>> @@ -485,7 +486,9 @@ void DescribeThread(AsanThreadContext *c
>> context->parent_tid,
>> ThreadNameWithParenthesis(context->parent_tid,
>> tname, sizeof(tname)));
>> - PrintStack(&context->stack);
>> + uptr stack_size;
>> + const uptr *stack_trace = StackDepotGet(context->stack_id, &stack_size);
>> + PrintStack(stack_trace, stack_size);
>> // Recursively described parent thread if needed.
>> if (flags()->print_full_thread_history) {
>> AsanThreadContext *parent_context =
>>
>> Modified: compiler-rt/trunk/lib/asan/asan_stack.cc
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_stack.cc?rev=192979&r1=192978&r2=192979&view=diff
>> ==============================================================================
>> --- compiler-rt/trunk/lib/asan/asan_stack.cc (original)
>> +++ compiler-rt/trunk/lib/asan/asan_stack.cc Fri Oct 18 09:50:44 2013
>> @@ -24,10 +24,13 @@ static bool MaybeCallAsanSymbolize(const
>> : false;
>> }
>>
>> -void PrintStack(StackTrace *stack) {
>> - StackTrace::PrintStack(stack->trace, stack->size, common_flags()->symbolize,
>> +void PrintStack(const uptr *trace, uptr size) {
>> + StackTrace::PrintStack(trace, size, common_flags()->symbolize,
>> MaybeCallAsanSymbolize);
>> }
>> +void PrintStack(StackTrace *stack) {
>> + PrintStack(stack->trace, stack->size);
>> +}
>>
>> } // namespace __asan
>>
>>
>> Modified: compiler-rt/trunk/lib/asan/asan_stack.h
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_stack.h?rev=192979&r1=192978&r2=192979&view=diff
>> ==============================================================================
>> --- compiler-rt/trunk/lib/asan/asan_stack.h (original)
>> +++ compiler-rt/trunk/lib/asan/asan_stack.h Fri Oct 18 09:50:44 2013
>> @@ -22,6 +22,7 @@
>> namespace __asan {
>>
>> void PrintStack(StackTrace *stack);
>> +void PrintStack(const uptr *trace, uptr size);
>>
>> } // namespace __asan
>>
>>
>> Modified: compiler-rt/trunk/lib/asan/asan_thread.cc
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_thread.cc?rev=192979&r1=192978&r2=192979&view=diff
>> ==============================================================================
>> --- compiler-rt/trunk/lib/asan/asan_thread.cc (original)
>> +++ compiler-rt/trunk/lib/asan/asan_thread.cc Fri Oct 18 09:50:44 2013
>> @@ -19,6 +19,7 @@
>> #include "asan_mapping.h"
>> #include "sanitizer_common/sanitizer_common.h"
>> #include "sanitizer_common/sanitizer_placement_new.h"
>> +#include "sanitizer_common/sanitizer_stackdepot.h"
>> #include "lsan/lsan_common.h"
>>
>> namespace __asan {
>> @@ -27,9 +28,8 @@ namespace __asan {
>>
>> void AsanThreadContext::OnCreated(void *arg) {
>> CreateThreadContextArgs *args = static_cast<CreateThreadContextArgs*>(arg);
>> - if (args->stack) {
>> - internal_memcpy(&stack, args->stack, sizeof(stack));
>> - }
>> + if (args->stack)
>> + stack_id = StackDepotPut(args->stack->trace, args->stack->size);
>> thread = args->thread;
>> thread->set_context(this);
>> }
>>
>> Modified: compiler-rt/trunk/lib/asan/asan_thread.h
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_thread.h?rev=192979&r1=192978&r2=192979&view=diff
>> ==============================================================================
>> --- compiler-rt/trunk/lib/asan/asan_thread.h (original)
>> +++ compiler-rt/trunk/lib/asan/asan_thread.h Fri Oct 18 09:50:44 2013
>> @@ -38,12 +38,12 @@ class AsanThreadContext : public ThreadC
>> : ThreadContextBase(tid),
>> announced(false),
>> destructor_iterations(kPthreadDestructorIterations),
>> + stack_id(0),
>> thread(0) {
>> - internal_memset(&stack, 0, sizeof(stack));
>> }
>> bool announced;
>> - int destructor_iterations;
>> - StackTrace stack;
>> + u8 destructor_iterations;
>> + u32 stack_id;
>> AsanThread *thread;
>>
>> void OnCreated(void *arg);
>> @@ -51,7 +51,7 @@ class AsanThreadContext : public ThreadC
>> };
>>
>> // AsanThreadContext objects are never freed, so we need many of them.
>> -COMPILER_CHECK(sizeof(AsanThreadContext) <= 4096);
>> +COMPILER_CHECK(sizeof(AsanThreadContext) <= 256);
>>
>> // AsanThread are stored in TSD and destroyed when the thread dies.
>> class AsanThread {
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
>
> --
> Alexander Potapenko
> Software Engineer
> Google Moscow
--
Alexander Potapenko
Software Engineer
Google Moscow
More information about the llvm-commits
mailing list