Reviewers: Mads Ager,
Description:
Fix bug 1433: clear the global thread table when an isolate is disposed.
[email protected]
BUG=v8:1433
TEST=test-lockers/Regress1433
Please review this at http://codereview.chromium.org/7129002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/isolate.h
M src/isolate.cc
M test/cctest/test-lockers.cc
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index
12c9753bfa4b943e3013c9628f07ce8a239f1f8d..1d8a8258d4bd5ef4921183c0ff7676ff410763ae
100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -1307,6 +1307,7 @@ char* Isolate::RestoreThread(char* from) {
if (RuntimeProfiler::IsEnabled() && current_vm_state() == JS) {
RuntimeProfiler::IsolateEnteredJS(this);
}
+ ASSERT(context() == NULL || context()->IsContext());
#endif
return from + sizeof(ThreadLocalTop);
}
@@ -1350,6 +1351,16 @@ void Isolate::ThreadDataTable::Remove(Isolate*
isolate,
}
+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
#define TRACE_ISOLATE(tag) \
do { \
@@ -1464,6 +1475,10 @@ void Isolate::TearDown() {
Deinit();
+ { ScopedLock lock(process_wide_mutex_);
+ thread_data_table_->RemoveAllThreads(this);
+ }
+
if (!IsDefaultIsolate()) {
delete this;
}
Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index
28bc44b1705df27f077ec70363952f691248fe59..bc78c6ddbb305204ff8e34cb194ae97f3f93d35e
100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -529,6 +529,7 @@ class Isolate {
// 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 @@ class Isolate {
void Insert(PerIsolateThreadData* data);
void Remove(Isolate* isolate, ThreadId thread_id);
void Remove(PerIsolateThreadData* data);
+ void RemoveAllThreads(Isolate* isolate);
private:
PerIsolateThreadData* list_;
Index: test/cctest/test-lockers.cc
diff --git a/test/cctest/test-lockers.cc b/test/cctest/test-lockers.cc
index
5b33f2ee06b7f8e50ca8ca46eb3f18b6424d97c7..9ca326448638daa27440009b2da7eb7c82b0e75e
100644
--- a/test/cctest/test-lockers.cc
+++ b/test/cctest/test-lockers.cc
@@ -607,3 +607,23 @@ TEST(LockUnlockLockDefaultIsolateMultithreaded) {
}
StartJoinAndDeleteThreads(threads);
}
+
+
+TEST(Regress1433) {
+ for (int i = 0; i < 10; i++) {
+ v8::Isolate* isolate = v8::Isolate::New();
+ {
+ v8::Locker l(isolate);
+ v8::Isolate::Scope iscope(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