Revision: 8209
Author: [email protected]
Date: Tue Jun 7 11:33:03 2011
Log: Fix bug 1433: clear the global thread table when an isolate is
disposed.
[email protected]
BUG=v8:1433
TEST=test-lockers/Regress1433
Review URL: http://codereview.chromium.org/7129002
http://code.google.com/p/v8/source/detail?r=8209
Modified:
/branches/bleeding_edge/src/isolate.cc
/branches/bleeding_edge/src/isolate.h
/branches/bleeding_edge/test/cctest/test-lockers.cc
=======================================
--- /branches/bleeding_edge/src/isolate.cc Mon Jun 6 08:43:08 2011
+++ /branches/bleeding_edge/src/isolate.cc Tue Jun 7 11:33:03 2011
@@ -1307,6 +1307,7 @@
if (RuntimeProfiler::IsEnabled() && current_vm_state() == JS) {
RuntimeProfiler::IsolateEnteredJS(this);
}
+ ASSERT(context() == NULL || context()->IsContext());
#endif
return from + sizeof(ThreadLocalTop);
}
@@ -1348,6 +1349,16 @@
Remove(data);
}
}
+
+
+void Isolate::ThreadDataTable::RemoveAllThreads(Isolate* isolate) {
+ PerIsolateThreadData* data = list_;
+ while (data != NULL) {
+ PerIsolateThreadData* next = data->next_;
+ if (data->isolate() == isolate) Remove(data);
+ data = next;
+ }
+}
#ifdef DEBUG
@@ -1463,6 +1474,10 @@
SetIsolateThreadLocals(this, NULL);
Deinit();
+
+ { ScopedLock lock(process_wide_mutex_);
+ thread_data_table_->RemoveAllThreads(this);
+ }
if (!IsDefaultIsolate()) {
delete this;
=======================================
--- /branches/bleeding_edge/src/isolate.h Mon Jun 6 08:43:08 2011
+++ /branches/bleeding_edge/src/isolate.h Tue Jun 7 11:33:03 2011
@@ -529,6 +529,7 @@
// Access to top context (where the current function object was created).
Context* context() { return thread_local_top_.context_; }
void set_context(Context* context) {
+ ASSERT(context == NULL || context->IsContext());
thread_local_top_.context_ = context;
}
Context** context_address() { return &thread_local_top_.context_; }
@@ -1003,6 +1004,7 @@
void Insert(PerIsolateThreadData* data);
void Remove(Isolate* isolate, ThreadId thread_id);
void Remove(PerIsolateThreadData* data);
+ void RemoveAllThreads(Isolate* isolate);
private:
PerIsolateThreadData* list_;
=======================================
--- /branches/bleeding_edge/test/cctest/test-lockers.cc Wed May 11 10:29:47
2011
+++ /branches/bleeding_edge/test/cctest/test-lockers.cc Tue Jun 7 11:33:03
2011
@@ -607,3 +607,23 @@
}
StartJoinAndDeleteThreads(threads);
}
+
+
+TEST(Regress1433) {
+ for (int i = 0; i < 10; i++) {
+ v8::Isolate* isolate = v8::Isolate::New();
+ {
+ v8::Locker lock(isolate);
+ v8::Isolate::Scope isolate_scope(isolate);
+ v8::HandleScope handle_scope;
+ v8::Persistent<Context> context = v8::Context::New();
+ v8::Context::Scope context_scope(context);
+ v8::Handle<String> source = v8::String::New("1+1");
+ v8::Handle<Script> script = v8::Script::Compile(source);
+ v8::Handle<Value> result = script->Run();
+ v8::String::AsciiValue ascii(result);
+ context.Dispose();
+ }
+ isolate->Dispose();
+ }
+}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev