review request Bug 17116 - StackTrace::SlowUnwindStack dead locked
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Thu Sep 12 01:20:21 PDT 2013
Thanks. I've replaced Stacktracing with Unwinding and committed as r190590.
On Wed, Sep 11, 2013 at 11:15 PM, Sergey Matveev <earthdok at google.com> wrote:
> Otherwise lgtm.
>
>
> On Wed, Sep 11, 2013 at 3:57 PM, Sergey Matveev <earthdok at google.com> wrote:
>>
>> Stacktrace is not a verb. Can we please call it "isUnwindingStack" etc?
>>
>> I will take a closer look at the code later today.
>>
>>
>> On Wed, Sep 11, 2013 at 3:13 PM, Evgeniy Stepanov
>> <eugeni.stepanov at gmail.com> wrote:
>>>
>>> Now we've got some allocations without stack traces, and it makes LSan
>>> sad.
>>>
>>> One of those is from after the AsanThread object is destroyed:
>>>
>>> #2 0x000000000044593f in __interceptor_malloc () at
>>> ../projects/compiler-rt/lib/asan/asan_malloc_linux.cc:74
>>> #3 0x0000000000459fc6 in key_destructor (arg=<optimized out>)
>>> at
>>> /code/llvm2/projects/compiler-rt/lib/lsan/lit_tests/TestCases/disabler_in_tsd_destructor.cc:17
>>> #4 0x00007ffff7bc4c83 in __nptl_deallocate_tsd () at
>>> pthread_create.c:156
>>> #5 0x00007ffff7bc4ea8 in start_thread (arg=0x7ffff2fff700) at
>>> pthread_create.c:315
>>> #6 0x00007ffff6cd3ccd in clone () at
>>> ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
>>>
>>> Attached patch makes LSan consider any such allocation reachable.
>>> I'll wait for Sergey to comment on this.
>>>
>>>
>>> On Wed, Sep 11, 2013 at 5:42 AM, 林作健 <manjian2006 at gmail.com> wrote:
>>> > Please review it.
>>> >
>>> >
>>> > Index: lib/asan/asan_thread.h
>>> > ===================================================================
>>> > --- lib/asan/asan_thread.h (revision 190475)
>>> > +++ lib/asan/asan_thread.h (working copy)
>>> > @@ -86,12 +86,19 @@
>>> > UnmapOrDie(fake_stack_, sizeof(FakeStack));
>>> > }
>>> > FakeStack *fake_stack() { return fake_stack_; }
>>> > + bool isStacktracing() const {
>>> > + return stacktracing;
>>> > + }
>>> > + void setStacktracing(bool b) {
>>> > + stacktracing = b;
>>> > + }
>>> >
>>> > AsanThreadLocalMallocStorage &malloc_storage() { return
>>> > malloc_storage_;
>>> > }
>>> > AsanStats &stats() { return stats_; }
>>> >
>>> > private:
>>> > - AsanThread() {}
>>> > + AsanThread()
>>> > + : stacktracing(false) {}
>>> > void SetThreadStackAndTls();
>>> > void ClearShadowForThreadStackAndTLS();
>>> > AsanThreadContext *context_;
>>> > @@ -105,8 +112,23 @@
>>> > FakeStack *fake_stack_;
>>> > AsanThreadLocalMallocStorage malloc_storage_;
>>> > AsanStats stats_;
>>> > + bool stacktracing;
>>> > };
>>> >
>>> > +// ScopedStacktracing is a scope for stacktracing member of a context
>>> > +class ScopedStacktracing {
>>> > + public:
>>> > + ScopedStacktracing (AsanThread * t)
>>> > + : thread(t) {
>>> > + t->setStacktracing(true);
>>> > + }
>>> > + ~ScopedStacktracing() {
>>> > + thread->setStacktracing(false);
>>> > + }
>>> > + private:
>>> > + AsanThread * thread;
>>> > +};
>>> > +
>>> > struct CreateThreadContextArgs {
>>> > AsanThread *thread;
>>> > StackTrace *stack;
>>> > Index: lib/asan/asan_stack.h
>>> > ===================================================================
>>> > --- lib/asan/asan_stack.h (revision 190475)
>>> > +++ lib/asan/asan_stack.h (working copy)
>>> > @@ -36,14 +36,16 @@
>>> > #define GET_STACK_TRACE_WITH_PC_AND_BP(max_s, pc, bp, fast) \
>>> > StackTrace stack; \
>>> > { \
>>> > - uptr stack_top = 0, stack_bottom = 0; \
>>> > AsanThread *t; \
>>> > - if (asan_inited && (t = GetCurrentThread())) { \
>>> > - stack_top = t->stack_top(); \
>>> > - stack_bottom = t->stack_bottom(); \
>>> > + stack.size = 0; \
>>> > + if (asan_inited && (t = GetCurrentThread()) \
>>> > + && !t->isStacktracing()) { \
>>> > + uptr stack_top = t->stack_top(); \
>>> > + uptr stack_bottom = t->stack_bottom(); \
>>> > + ScopedStacktracing sink(t); \
>>> > + GetStackTrace(&stack, max_s, pc, bp, \
>>> > + stack_top, stack_bottom, fast); \
>>> > } \
>>> > - GetStackTrace(&stack, max_s, pc, bp, \
>>> > - stack_top, stack_bottom, fast); \
>>> > }
>>> > #endif // SANITIZER_WINDOWS
>>> >
>>> >
>>> >
>>> >
>>> > 2013/9/10 Evgeniy Stepanov <eugeni.stepanov at gmail.com>
>>> >>
>>> >> On Mon, Sep 9, 2013 at 2:09 PM, 林作健 <manjian2006 at gmail.com> wrote:
>>> >> > Index: lib/asan/asan_thread.h
>>> >> > ===================================================================
>>> >> > --- lib/asan/asan_thread.h (revision 190121)
>>> >> > +++ lib/asan/asan_thread.h (working copy)
>>> >> > @@ -36,10 +36,12 @@
>>> >> > explicit AsanThreadContext(int tid)
>>> >> > : ThreadContextBase(tid),
>>> >> > announced(false),
>>> >> > + stacktracing(false),
>>> >> > thread(0) {
>>> >> > internal_memset(&stack, 0, sizeof(stack));
>>> >> > }
>>> >> > bool announced;
>>> >> > + bool stacktracing;
>>> >>
>>> >> Thread context objects live forever. Please move this to AsanThread.
>>> >>
>>> >> > StackTrace stack;
>>> >> > AsanThread *thread;
>>> >> >
>>> >> > @@ -86,6 +88,12 @@
>>> >> > UnmapOrDie(fake_stack_, sizeof(FakeStack));
>>> >> > }
>>> >> > FakeStack *fake_stack() { return fake_stack_; }
>>> >> > + bool isStacktracing() {
>>> >> > + if (context()) {
>>> >> > + return context()->stacktracing;
>>> >> > + }
>>> >> > + return false;
>>> >> > + }
>>> >> >
>>> >> > AsanThreadLocalMallocStorage &malloc_storage() { return
>>> >> > malloc_storage_;
>>> >> > }
>>> >> > AsanStats &stats() { return stats_; }
>>> >> > @@ -107,6 +115,24 @@
>>> >> > AsanStats stats_;
>>> >> > };
>>> >> >
>>> >> > +// AsanStacktracingSink is a sink for stacktracing member of a
>>> >> > context
>>> >> > +class AsanStacktracingSink {
>>> >>
>>> >> Please call it ScopedSomething. M/b ScopedInStackTrace or
>>> >> ScopedStacktracing.
>>> >>
>>> >> > + public:
>>> >> > + AsanStacktracingSink(AsanThread * t)
>>> >> > + : thread(t) {
>>> >> > + if(t->context()) {
>>> >> > + t->context()->stacktracing = true;
>>> >> > + }
>>> >> > + }
>>> >> > + ~AsanStacktracingSink() {
>>> >> > + if(thread->context()) {
>>> >> > + thread->context()->stacktracing = false;
>>> >> > + }
>>> >> > + }
>>> >> > + private:
>>> >> > + AsanThread * thread;
>>> >> > +};
>>> >> > +
>>> >> > struct CreateThreadContextArgs {
>>> >> > AsanThread *thread;
>>> >> > StackTrace *stack;
>>> >> > Index: lib/asan/asan_stack.h
>>> >> > ===================================================================
>>> >> > --- lib/asan/asan_stack.h (revision 190121)
>>> >> > +++ lib/asan/asan_stack.h (working copy)
>>> >> > @@ -36,14 +36,16 @@
>>> >> > #define GET_STACK_TRACE_WITH_PC_AND_BP(max_s, pc, bp, fast) \
>>> >> > StackTrace stack; \
>>> >> > { \
>>> >> > - uptr stack_top = 0, stack_bottom = 0; \
>>> >> > AsanThread *t; \
>>> >> > - if (asan_inited && (t = GetCurrentThread())) { \
>>> >> > - stack_top = t->stack_top(); \
>>> >> > - stack_bottom = t->stack_bottom(); \
>>> >> > + stack.size = 0; \
>>> >> > + if (asan_inited && (t = GetCurrentThread()) \
>>> >> > + && !t->isStacktracing()) { \
>>> >> > + uptr stack_top = t->stack_top(); \
>>> >> > + uptr stack_bottom = t->stack_bottom(); \
>>> >> > + AsanStacktracingSink sink(t); \
>>> >> > + GetStackTrace(&stack, max_s, pc, bp, \
>>> >> > + stack_top, stack_bottom, fast); \
>>> >> > } \
>>> >> > - GetStackTrace(&stack, max_s, pc, bp, \
>>> >> > - stack_top, stack_bottom, fast); \
>>> >> > }
>>> >> > #endif // SANITIZER_WINDOWS
>>> >> >
>>> >> >
>>> >> > _______________________________________________
>>> >> > llvm-commits mailing list
>>> >> > llvm-commits at cs.uiuc.edu
>>> >> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>> >> >
>>> >
>>> >
>>
>>
>
More information about the llvm-commits
mailing list