[llvm-commits] [compiler-rt] r161770 - in /compiler-rt/trunk/lib/tsan/go: buildgo.sh tsan_go.cc
Dmitry Vyukov
dvyukov at google.com
Mon Aug 13 11:44:44 PDT 2012
Author: dvyukov
Date: Mon Aug 13 13:44:44 2012
New Revision: 161770
URL: http://llvm.org/viewvc/llvm-project?rev=161770&view=rev
Log:
tsan: handle larger number of goroutines + fix a memory leak of goroutine descriptors
Modified:
compiler-rt/trunk/lib/tsan/go/buildgo.sh
compiler-rt/trunk/lib/tsan/go/tsan_go.cc
Modified: compiler-rt/trunk/lib/tsan/go/buildgo.sh
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/go/buildgo.sh?rev=161770&r1=161769&r2=161770&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/go/buildgo.sh (original)
+++ compiler-rt/trunk/lib/tsan/go/buildgo.sh Mon Aug 13 13:44:44 2012
@@ -33,7 +33,6 @@
../../sanitizer_common/sanitizer_libc.cc
../../sanitizer_common/sanitizer_posix.cc
../../sanitizer_common/sanitizer_printf.cc
- ../../sanitizer_common/sanitizer_symbolizer.cc
"
if [ "$LINUX" != "" ]; then
@@ -42,10 +41,10 @@
../../sanitizer_common/sanitizer_linux.cc
"
elif [ "$MAC" != "" ]; then
- SRCS+="
- ../rtl/tsan_platform_mac.cc
- ../../sanitizer_common/sanitizer_mac.cc
- "
+ SRCS+="
+ ../rtl/tsan_platform_mac.cc
+ ../../sanitizer_common/sanitizer_mac.cc
+ "
fi
SRCS+=$ADD_SRCS
Modified: compiler-rt/trunk/lib/tsan/go/tsan_go.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/go/tsan_go.cc?rev=161770&r1=161769&r2=161770&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/go/tsan_go.cc (original)
+++ compiler-rt/trunk/lib/tsan/go/tsan_go.cc Mon Aug 13 13:44:44 2012
@@ -18,7 +18,9 @@
namespace __tsan {
-static ThreadState *goroutines[kMaxTid];
+const int kMaxGoroutinesEver = 128*1024;
+
+static ThreadState *goroutines[kMaxGoroutinesEver];
void InitializeInterceptors() {
}
@@ -79,9 +81,14 @@
extern "C" {
static void AllocGoroutine(int tid) {
- goroutines[tid] = (ThreadState*)internal_alloc(MBlockThreadContex,
+ if (tid >= kMaxGoroutinesEver) {
+ Printf("FATAL: Reached goroutine limit\n");
+ Die();
+ }
+ ThreadState *thr = (ThreadState*)internal_alloc(MBlockThreadContex,
sizeof(ThreadState));
- internal_memset(goroutines[tid], 0, sizeof(ThreadState));
+ internal_memset(thr, 0, sizeof(*thr));
+ goroutines[tid] = thr;
}
void __tsan_init() {
@@ -152,6 +159,8 @@
thr->in_rtl++;
ThreadFinish(thr);
thr->in_rtl--;
+ internal_free(thr);
+ goroutines[goid] = 0;
}
void __tsan_acquire(int goid, void *addr) {
@@ -159,7 +168,6 @@
thr->in_rtl++;
Acquire(thr, 0, (uptr)addr);
thr->in_rtl--;
- //internal_free(thr);
}
void __tsan_release(int goid, void *addr) {
More information about the llvm-commits
mailing list