review request Bug 17116 - StackTrace::SlowUnwindStack dead locked
林作健
manjian2006 at gmail.com
Mon Sep 9 03:09:06 PDT 2013
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;
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 {
+ 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130909/6f906787/attachment.html>
More information about the llvm-commits
mailing list