Changeset 97280 in webkit


Ignore:
Timestamp:
Oct 12, 2011 11:45:47 AM (13 years ago)
Author:
Nate Chapin
Message:

Remove logging to determine how null v8::Contexts are happening,
and check the return value of V8DOMWindowShell::initContextIfNeeded()
before using the context it initialized.
https://bugs.webkit.org/show_bug.cgi?id=68099

Reviewed by Adam Barth.

No new tests, the only symptom is a crash without a known repro.

  • bindings/v8/ScriptController.cpp:
  • bindings/v8/V8DOMWindowShell.cpp:

(WebCore::V8DOMWindowShell::initContextIfNeeded): Return true

if a context already existed.

(WebCore::V8DOMWindowShell::namedItemAdded): Remove logging.

  • bindings/v8/V8Proxy.cpp:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r97278 r97280  
     12011-10-12  Nate Chapin  <japhet@chromium.org>
     2
     3        Remove logging to determine how null v8::Contexts are happening,
     4        and check the return value of V8DOMWindowShell::initContextIfNeeded()
     5        before using the context it initialized.
     6        https://bugs.webkit.org/show_bug.cgi?id=68099
     7
     8        Reviewed by Adam Barth.
     9
     10        No new tests, the only symptom is a crash without a known repro.
     11
     12        * bindings/v8/ScriptController.cpp:
     13        * bindings/v8/V8DOMWindowShell.cpp:
     14        (WebCore::V8DOMWindowShell::initContextIfNeeded): Return true
     15            if a context already existed.
     16        (WebCore::V8DOMWindowShell::namedItemAdded): Remove logging.
     17        * bindings/v8/V8Proxy.cpp:
     18
    1192011-10-06  Robert Hogan  <robert@webkit.org>
    220
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r97109 r97280  
    27272727        proxy = V8Proxy::retrieve(impl->document()->frame());
    27282728        if (proxy && static_cast<Node*>(impl->document()) == static_cast<Node*>(impl)) {
    2729             if (proxy->windowShell()->initContextIfNeeded()) {
     2729            if (proxy->windowShell()->context().IsEmpty() && proxy->windowShell()->initContextIfNeeded()) {
    27302730                // initContextIfNeeded may have created a wrapper for the object, retry from the start.
    27312731                return ${className}::wrap(impl);
  • trunk/Source/WebCore/bindings/v8/ScriptController.cpp

    r96991 r97280  
    270270void ScriptController::disableEval()
    271271{
    272     m_proxy->windowShell()->initContextIfNeeded();
     272    if (!m_proxy->windowShell()->initContextIfNeeded())
     273        return;
    273274
    274275    v8::HandleScope handleScope;
  • trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp

    r96357 r97280  
    7878
    7979namespace WebCore {
    80 
    81 // FIXME: Temporary diagnostics as to why V8 sometimes crashes with a null context in namedItemAdded().
    82 // See https://bugs.webkit.org/show_bug.cgi?id=68099.
    83 static int s_contextFailureReason = -1;
    8480
    8581static void handleFatalErrorInV8()
     
    282278    // Bail out if the context has already been initialized.
    283279    if (!m_context.IsEmpty())
    284         return false;
     280        return true;
    285281
    286282    // Create a handle scope for all local handles.
     
    323319        if (m_global.IsEmpty()) {
    324320            disposeContextHandles();
    325             s_contextFailureReason = 3;
    326321            return false;
    327322        }
     
    359354
    360355    // The activeDocumentLoader pointer could be 0 during frame shutdown.
    361     if (!m_frame->loader()->activeDocumentLoader()) {
    362         s_contextFailureReason = 0;
     356    if (!m_frame->loader()->activeDocumentLoader())
    363357        return result;
    364     }
    365358
    366359    // Create a new environment using an empty template for the shadow
    367360    // object. Reuse the global object if one has been created earlier.
    368361    v8::Persistent<v8::ObjectTemplate> globalTemplate = V8DOMWindow::GetShadowObjectTemplate();
    369     if (globalTemplate.IsEmpty()) {
    370         s_contextFailureReason = 1;
     362    if (globalTemplate.IsEmpty())
    371363        return result;
    372     }
    373364
    374365    // Used to avoid sleep calls in unload handlers.
     
    397388    result = v8::Context::New(&extensionConfiguration, globalTemplate, global);
    398389
    399     if (result.IsEmpty())
    400         s_contextFailureReason = 2;
    401390    return result;
    402391}
     
    418407    v8::Local<v8::Object> jsWindow = SafeAllocation::newInstance(windowConstructor);
    419408    // Bail out if allocation failed.
    420     if (jsWindow.IsEmpty()) {
    421         s_contextFailureReason = 7;
     409    if (jsWindow.IsEmpty())
    422410        return false;
    423     }
    424411
    425412    // Wrap the window.
     
    552539    // context for the new document to make property access on the
    553540    // global object wrapper succeed.
    554     initContextIfNeeded();
    555 
    556     // Bail out if context initialization failed.
    557     if (m_context.IsEmpty())
     541    if (!initContextIfNeeded())
    558542        return;
    559543
     
    581565void V8DOMWindowShell::namedItemAdded(HTMLDocument* doc, const AtomicString& name)
    582566{
    583     initContextIfNeeded();
    584 
    585     if (!isContextInitialized()) {
    586 #if PLATFORM(CHROMIUM)
    587         // FIXME: Temporary diagnostics as to why V8 sometimes crashes with a null context below.
    588         // See https://bugs.webkit.org/show_bug.cgi?id=68099.
    589         PlatformSupport::histogramEnumeration("V8Bindings.nullContextState", 0, 3);
    590         if (m_frame->settings() && !m_frame->settings()->isJavaScriptEnabled())
    591             PlatformSupport::histogramEnumeration("V8Bindings.nullContextState", 1, 3);
    592 
    593         if (!m_frame->script()->canExecuteScripts(NotAboutToExecuteScript))
    594             PlatformSupport::histogramEnumeration("V8Bindings.nullContextState", 2, 3);
    595 
    596         if (s_contextFailureReason >= 0 && s_contextFailureReason <= 7)
    597             PlatformSupport::histogramEnumeration("V8Bindings.nullContextReason", s_contextFailureReason, 8);
    598         s_contextFailureReason = -1;
    599 #endif
    600         return;
    601     }
     567    if (!initContextIfNeeded())
     568        return;
    602569
    603570    v8::HandleScope handleScope;
     
    630597    v8::Handle<v8::String> hiddenObjectPrototypeString = V8HiddenPropertyName::objectPrototype();
    631598    // Bail out if allocation failed.
    632     if (objectString.IsEmpty() || prototypeString.IsEmpty() || hiddenObjectPrototypeString.IsEmpty()) {
    633         s_contextFailureReason = 4;
     599    if (objectString.IsEmpty() || prototypeString.IsEmpty() || hiddenObjectPrototypeString.IsEmpty())
    634600        return false;
    635     }
    636601
    637602    v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(context->Global()->Get(objectString));
    638603    // Bail out if fetching failed.
    639     if (object.IsEmpty()) {
    640         s_contextFailureReason = 5;
     604    if (object.IsEmpty())
    641605        return false;
    642     }
    643606    v8::Handle<v8::Value> objectPrototype = object->Get(prototypeString);
    644607    // Bail out if fetching failed.
    645     if (objectPrototype.IsEmpty()) {
    646         s_contextFailureReason = 6;
     608    if (objectPrototype.IsEmpty())
    647609        return false;
    648     }
    649610
    650611    context->Global()->SetHiddenValue(hiddenObjectPrototypeString, objectPrototype);
     
    656617{
    657618    // Not in cache.
    658     initContextIfNeeded();
     619    if (!initContextIfNeeded())
     620        return notHandledByInterceptor();
     621
    659622    v8::Context::Scope scope(m_context);
    660623    v8::Local<v8::Function> function = V8DOMWrapper::getConstructor(type, getHiddenObjectPrototype(m_context));
  • trunk/Source/WebCore/bindings/v8/V8Proxy.cpp

    r95901 r97280  
    246246{
    247247    // FIXME: This will need to get reorganized once we have a windowShell for the isolated world.
    248     windowShell()->initContextIfNeeded();
     248    if (!windowShell()->initContextIfNeeded())
     249        return;
    249250
    250251    v8::HandleScope handleScope;
Note: See TracChangeset for help on using the changeset viewer.