Status: New
Owner: ----

New issue 3639 by [email protected]: v3.29 crash when Context::New() called from CGO
https://code.google.com/p/v8/issues/detail?id=3639

Hi.

I have a Go project named v8.go. It used to binding V8 engine to Go program.

I try to upgrade the V8 engine version to 3.29. But my unit test always crash when a Context::New() called.

The crash call it's not the first and even not in the first hundred. Because I have some thread safe test before the crashed test, they create many context for testing.

And when I take out the crashed test run it alone, it passed. So it's some kind of random crash. But when all unit test run, it always crash at that point.

I try to add may printf to trace the crash point. I found the crash point it's in Execution::InstantiateFunction().

    MaybeHandle<JSFunction> Execution::InstantiateFunction(
        Handle<FunctionTemplateInfo> data) {
      printf("y00\n");
      Isolate* isolate = data->GetIsolate();
      if (!data->do_not_cache()) {
      printf("y11\n");
        // Fast case: see if the function has already been instantiated
        int serial_number = Smi::cast(data->serial_number())->value();
        Handle<JSObject> cache(isolate->native_context()->function_cache());
        Handle<Object> elm =
Object::GetElement(isolate, cache, serial_number).ToHandleChecked();
        if (elm->IsJSFunction()) return Handle<JSFunction>::cast(elm);
      }
      printf("y22\n");
      // The function has not yet been instantiated in this context; do it.
      Handle<Object> args[] = { data };
      Handle<Object> result;
      ASSIGN_RETURN_ON_EXCEPTION(
          isolate, result,
          Call(isolate,
               isolate->instantiate_fun(),
               isolate->js_builtins_object(),
               arraysize(args),
               args),
          JSFunction);
      printf("y33\n");
      return Handle<JSFunction>::cast(result);
    }

The program print y22 and crash. I can't found the instantiate_fun() in V8 source code so I don't know what happens in it.

The v8.go work correct with version 3.28.

I found the different between 3.28 and 3.29 it's the V8::Initialize() need invoked by manual.

In v8.go I use the Locker::Locker(isolate) to make sure every thread have init before it using V8.

Because Go use different threads to execute cgo calls.

I think 3.29 changed some thread init logic, the new logic not friendly to cgo call.

Maybe I need to call so thread init function by manual when every cgo call begins?

--
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