Page 1 of 1

renderer process crash with js extension defining "external"

PostPosted: Tue Dec 13, 2016 7:46 pm
by sbush1310
After upgrading from 2785.1480 to 2883.1539, I discovered that "external" has now become a reserved variable within V8. The reason we were using "external" was to provide backwards compatibility for our application which previously was using embedded IE controls that interacted with the application via a javascript object named "external". This worked fine for prior versions of CEF, but starting with 2883.1539, the renderer process crashes during initialization with the information shown below with debugging symbols present. The fix for myself was to rename the js object within the V8 extension from "external" to something else and update our html and js files accordingly to make use of the changed name.

During OnWebKitInitialized(), I set up the following code based on: https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md#markdown-header-functions-and-extensions
Code: Select all
   class JSHandler : public CefV8Handler
   {
        //snip implementation
   };



const char* const DoLinkExtension_Name = "v8/external";
const char* const DoLinkExtension =
   "var external;"
   "if (!external)"
   "  external = {};"
   "(function() {"
   "  external.DoLink = function(linkinfo) {"
   "    native function DoLink();"
   "    return DoLink(linkinfo);"
   "  };"
   "})();";


   
   CefRefPtr<CefV8Handler> handler = new JSHandler();

   CefRegisterExtension(DoLinkExtension_Name, DoLinkExtension, handler);


However, during startup, the render process crashes inside V8 with the following stack trace:

Code: Select all
   libcef.dll!blink::reportFatalErrorInMainThread(const char * location, const char * message) Line 100   C++
    libcef.dll!v8::DecodeSmiToAligned(v8::internal::Object * value, const char *) Line 973   C++
    libcef.dll!blink::getInternalField<blink::ScriptWrappable,1>(v8::Local<v8::Object> wrapper) Line 224   C++
    libcef.dll!blink::DOMWindowV8Internal::externalAttributeGetter(const v8::PropertyCallbackInfo<v8::Value> & info) Line 972   C++
    libcef.dll!blink::DOMWindowV8Internal::externalAttributeGetterCallback(v8::Local<v8::Name> __formal, const v8::PropertyCallbackInfo<v8::Value> & info) Line 988   C++
    libcef.dll!v8::internal::PropertyCallbackArguments::Call(void (v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value> &) * f, v8::internal::Handle<v8::internal::Name> name) Line 32   C++
    libcef.dll!v8::internal::Object::GetPropertyWithAccessor(v8::internal::LookupIterator * it) Line 1353   C++
    libcef.dll!v8::internal::Object::GetProperty(v8::internal::LookupIterator * it) Line 998   C++
    libcef.dll!v8::internal::LoadIC::Load(v8::internal::Handle<v8::internal::Object> object, v8::internal::Handle<v8::internal::Name> name) Line 636   C++
    libcef.dll!v8::internal::LoadGlobalIC::Load(v8::internal::Handle<v8::internal::Name> name) Line 678   C++
    libcef.dll!v8::internal::__RT_impl_Runtime_LoadGlobalIC_Miss(v8::internal::Arguments args, v8::internal::Isolate * isolate) Line 2319   C++
    libcef.dll!v8::internal::Runtime_LoadGlobalIC_Miss(int args_length, v8::internal::Object * * args_object, v8::internal::Isolate * isolate) Line 2300   C++



location = "v8::Object::GetAlignedPointerFromInternalField()"
message = "Not a Smi";

changing the DoLinkExtension above to use var "myExternal" instead of "external" eliminates the crash.