[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:37:13 PDT 2013


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



More information about the llvm-commits mailing list