review request Bug 17116 - StackTrace::SlowUnwindStack dead locked
林作健
manjian2006 at gmail.com
Tue Sep 10 18:42:33 PDT 2013
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
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130911/80966a10/attachment.html>
More information about the llvm-commits
mailing list