Ignore:
Timestamp:
Mar 19, 2008, 6:00:15 PM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2008-03-19 Sam Weinig <[email protected]>

Reviewed by Anders Carlsson.

Fix for <rdar://problem/5785694>
Crash occurs at KJS::Collector::collect() when loading web clip widgets with a PAC file

Make the activeExecStates stack per JSGlobalObject instead of static to ensure
thread safety.

  • JavaScriptCore.exp:
  • kjs/ExecState.cpp: (KJS::InterpreterExecState::InterpreterExecState): (KJS::InterpreterExecState::~InterpreterExecState): (KJS::EvalExecState::EvalExecState): (KJS::EvalExecState::~EvalExecState): (KJS::FunctionExecState::FunctionExecState): (KJS::FunctionExecState::~FunctionExecState):
  • kjs/ExecState.h: (KJS::):
  • kjs/JSGlobalObject.cpp: (KJS::JSGlobalObject::mark):
  • kjs/JSGlobalObject.h: (KJS::JSGlobalObject::activeExecStates):
  • kjs/collector.cpp: (KJS::Collector::collect): (KJS::Collector::reportOutOfMemoryToAllExecStates): Iterate all JSGlobalObjects and report the OutOfMemory condition to all the ExecStates in each.

WebCore:

2008-03-19 Sam Weinig <[email protected]>

Reviewed by Anders Carlsson.

Fix for <rdar://problem/5785694>
Crash occurs at KJS::Collector::collect() when loading web clip widgets with a PAC file

Make the activeExecStates stack per JSGlobalObject instead of static to ensure
thread safety.

  • bindings/objc/WebScriptObject.mm: (+[WebScriptObject throwException:]): Change to throw an exception on the current GlobalObject instead of the top of the static activeExecStates stack. (-[WebScriptObject setException:]): Change to use the top of the rootObjects GlobalObject instead of the top of the static activeExecStates stack.
  • bridge/c/c_instance.cpp:
  • bridge/c/c_instance.h:
  • bridge/jni/jni_instance.cpp: (JavaInstance::virtualBegin): (JavaInstance::virtualEnd):
  • bridge/jni/jni_instance.h:
  • bridge/objc/objc_instance.h:
  • bridge/objc/objc_instance.mm: (ObjcInstance::~ObjcInstance): (ObjcInstance::virtualBegin): (ObjcInstance::virtualEnd):
  • bridge/runtime.cpp: (KJS::Bindings::Instance::setDidExecuteFunction): (KJS::Bindings::Instance::didExecuteFunction): (KJS::Bindings::Instance::setCurrentGlobalObject): Added. (KJS::Bindings::Instance::currentGlobalObject): Added. (KJS::Bindings::Instance::begin): (KJS::Bindings::Instance::end):
  • bridge/runtime.h: (KJS::Bindings::Instance::virtualBegin): Renamed from begin(). (KJS::Bindings::Instance::virtualEnd): Renamed from end(). We now store the currently active globalObject everytime we cross the runtime object boundary. To do this, we take advantage of the existing begin/end methods that are called when crossing this boundary, making begin set the current globalObject and then call the old begin, now called virtualBegin.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/collector.cpp

    r30576 r31167  
    936936  markStackObjectsConservatively();
    937937  markProtectedObjects();
    938   ExecState::markActiveExecStates();
    939938  List::markProtectedLists();
    940939#if USE(MULTIPLE_THREADS)
     
    10461045void Collector::reportOutOfMemoryToAllExecStates()
    10471046{
    1048     ExecStateStack::const_iterator end = ExecState::activeExecStates().end();
    1049     for (ExecStateStack::const_iterator it = ExecState::activeExecStates().begin(); it != end; ++it) {
    1050         (*it)->setException(Error::create(*it, GeneralError, "Out of memory"));
    1051     }
     1047    if (!JSGlobalObject::head())
     1048        return;
     1049
     1050    JSGlobalObject* globalObject = JSGlobalObject::head();
     1051    do {
     1052        ExecStateStack::const_iterator end = globalObject->activeExecStates().end();
     1053        for (ExecStateStack::const_iterator it = globalObject->activeExecStates().begin(); it != end; ++it)
     1054            (*it)->setException(Error::create(*it, GeneralError, "Out of memory"));
     1055        globalObject = globalObject->next();
     1056    } while (globalObject != JSGlobalObject::head());
    10521057}
    10531058
Note: See TracChangeset for help on using the changeset viewer.