Status: New
Owner: ----

New issue 3374 by [email protected]: A compatibility problem of v8`s default isolate
http://code.google.com/p/v8/issues/detail?id=3374

I use the newest code in the trunk of v8, and I found a core dump, when I execute the hello_world program in the link "https://developers.google.com/v8/get_started";.
I think it is a compatibility problem.

The reason of core dump is analyzed as below:

In hello_world.cc, the code is:
  // Get the default Isolate created at startup.
  Isolate* isolate = Isolate::GetCurrent();  // --here is the problem

  // Create a stack-allocated handle scope.
  HandleScope handle_scope(isolate);

  // Create a new context.
  Handle<Context> context = Context::New(isolate);

when i debug the core dump file, i found the pointer of "isolate" is a null pointer.

Program received signal SIGSEGV, Segmentation fault.
0x0000000000414883 in v8::HandleScope::Initialize (this=0x7fffffffe3c0, isolate=0x0) at ../src/api.cc:572
572       prev_next_ = current->next;
(gdb) bt
#0 0x0000000000414883 in v8::HandleScope::Initialize (this=0x7fffffffe3c0, isolate=0x0) at ../src/api.cc:572 #1 0x0000000000414805 in v8::HandleScope::HandleScope (this=0x7fffffffe3c0, isolate=0x0) at ../src/api.cc:557
#2  0x0000000000403871 in main ()
(gdb) p current
$1 = (v8::internal::HandleScopeData *) 0x3530
(gdb)

By analyzing, I found that it caused by the modify of function "EnsureDefaultIsolate". The process of default isolate is changed, and in the new version, there will not be a default isolate,
so the functin "Isolate::GetCurrent()" will return a NULL pointer.

This problem will make those software that based on old v8 version unusable when they update to a new version.

At last the code:

In the old release version of V8:
void Isolate::EnsureDefaultIsolate() {
  LockGuard<Mutex> lock_guard(&process_wide_mutex_);
  CHECK(default_isolate_status_ != kDefaultIsolateCrashIfInitialized);
  if (default_isolate_ == NULL) {
    isolate_key_ = Thread::CreateThreadLocalKey();
    thread_id_key_ = Thread::CreateThreadLocalKey();
    per_isolate_thread_data_key_ = Thread::CreateThreadLocalKey();
#ifdef DEBUG
PerThreadAssertScopeBase::thread_local_key = Thread::CreateThreadLocalKey();
#endif  // DEBUG
    thread_data_table_ = new Isolate::ThreadDataTable();
    default_isolate_ = new Isolate();
 }
  // Can't use SetIsolateThreadLocals(default_isolate_, NULL) here
  // because a non-null thread data may be already set.
 if (Thread::GetThreadLocal(isolate_key_) == NULL) {
    Thread::SetThreadLocal(isolate_key_, default_isolate_);
 }
}

And in the newest code:
void Isolate::EnsureDefaultIsolate() {
  LockGuard<Mutex> lock_guard(&process_wide_mutex_);
  CHECK(default_isolate_status_ != kDefaultIsolateCrashIfInitialized);
  if (default_isolate_ == NULL) {
    isolate_key_ = Thread::CreateThreadLocalKey();
    thread_id_key_ = Thread::CreateThreadLocalKey();
    per_isolate_thread_data_key_ = Thread::CreateThreadLocalKey();
#ifdef DEBUG
PerThreadAssertScopeBase::thread_local_key = Thread::CreateThreadLocalKey();
#endif  // DEBUG
    thread_data_table_ = new Isolate::ThreadDataTable();
  }
}


--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to