Changeset 122463 in webkit


Ignore:
Timestamp:
Jul 12, 2012 8:38:14 AM (12 years ago)
Author:
jsbell@chromium.org
Message:

IndexedDB: ASSERT hit calling open from callback in Worker
https://bugs.webkit.org/show_bug.cgi?id=90832

Reviewed by Kentaro Hara.

Source/WebCore:

GroupSettings are used to provide the backing store path in some
ports. Accessing those settings from a Worker was added, but the
access referenced thread startup data that is cleared before the
run loop, so an IDBFactory.open() call executed asynchronously
would dereference a null pointer. Plumb the settings startup
data into the context itself, like all of the other properties.

Test: storage/indexeddb/open-twice-workers.html

  • Modules/indexeddb/IDBFactory.cpp:

(WebCore::IDBFactory::open):

  • workers/DedicatedWorkerContext.cpp:

(WebCore::DedicatedWorkerContext::DedicatedWorkerContext):

  • workers/DedicatedWorkerContext.h:

(WebCore::DedicatedWorkerContext::create):
(DedicatedWorkerContext):

  • workers/DedicatedWorkerThread.cpp:

(WebCore::DedicatedWorkerThread::createWorkerContext):

  • workers/DedicatedWorkerThread.h:

(DedicatedWorkerThread):

  • workers/SharedWorkerContext.cpp:

(WebCore::SharedWorkerContext::SharedWorkerContext):

  • workers/SharedWorkerContext.h:

(WebCore::SharedWorkerContext::create):
(SharedWorkerContext):

  • workers/SharedWorkerThread.cpp:

(WebCore::SharedWorkerThread::createWorkerContext):

  • workers/SharedWorkerThread.h:

(SharedWorkerThread):

  • workers/WorkerContext.cpp:

(WebCore::WorkerContext::WorkerContext):

  • workers/WorkerContext.h:

(WebCore::WorkerContext::groupSettings):
(WorkerContext):

  • workers/WorkerThread.cpp:

(WebCore::WorkerThread::workerThread):

  • workers/WorkerThread.h:

(WorkerThread):

LayoutTests:

Call IDBFactory.open() twice from a worker - once from the initial worker
script evaluation, and once in a callback after the worker thread data
has been purged.

  • storage/indexeddb/open-twice-workers-expected.txt: Added.
  • storage/indexeddb/open-twice-workers.html: Added.
  • storage/indexeddb/resources/open-twice.js: Added.

(test):
(openAnother):

Location:
trunk
Files:
3 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r122458 r122463  
     12012-07-12  Joshua Bell  <jsbell@chromium.org>
     2
     3        IndexedDB: ASSERT hit calling open from callback in Worker
     4        https://bugs.webkit.org/show_bug.cgi?id=90832
     5
     6        Reviewed by Kentaro Hara.
     7
     8        Call IDBFactory.open() twice from a worker - once from the initial worker
     9        script evaluation, and once in a callback after the worker thread data
     10        has been purged.
     11
     12        * storage/indexeddb/open-twice-workers-expected.txt: Added.
     13        * storage/indexeddb/open-twice-workers.html: Added.
     14        * storage/indexeddb/resources/open-twice.js: Added.
     15        (test):
     16        (openAnother):
     17
    1182012-07-12  Kristóf Kosztyó  <kkristof@inf.u-szeged.hu>
    219
  • trunk/Source/WebCore/ChangeLog

    r122462 r122463  
     12012-07-12  Joshua Bell  <jsbell@chromium.org>
     2
     3        IndexedDB: ASSERT hit calling open from callback in Worker
     4        https://bugs.webkit.org/show_bug.cgi?id=90832
     5
     6        Reviewed by Kentaro Hara.
     7
     8        GroupSettings are used to provide the backing store path in some
     9        ports. Accessing those settings from a Worker was added, but the
     10        access referenced thread startup data that is cleared before the
     11        run loop, so an IDBFactory.open() call executed asynchronously
     12        would dereference a null pointer. Plumb the settings startup
     13        data into the context itself, like all of the other properties.
     14
     15        Test: storage/indexeddb/open-twice-workers.html
     16
     17        * Modules/indexeddb/IDBFactory.cpp:
     18        (WebCore::IDBFactory::open):
     19        * workers/DedicatedWorkerContext.cpp:
     20        (WebCore::DedicatedWorkerContext::DedicatedWorkerContext):
     21        * workers/DedicatedWorkerContext.h:
     22        (WebCore::DedicatedWorkerContext::create):
     23        (DedicatedWorkerContext):
     24        * workers/DedicatedWorkerThread.cpp:
     25        (WebCore::DedicatedWorkerThread::createWorkerContext):
     26        * workers/DedicatedWorkerThread.h:
     27        (DedicatedWorkerThread):
     28        * workers/SharedWorkerContext.cpp:
     29        (WebCore::SharedWorkerContext::SharedWorkerContext):
     30        * workers/SharedWorkerContext.h:
     31        (WebCore::SharedWorkerContext::create):
     32        (SharedWorkerContext):
     33        * workers/SharedWorkerThread.cpp:
     34        (WebCore::SharedWorkerThread::createWorkerContext):
     35        * workers/SharedWorkerThread.h:
     36        (SharedWorkerThread):
     37        * workers/WorkerContext.cpp:
     38        (WebCore::WorkerContext::WorkerContext):
     39        * workers/WorkerContext.h:
     40        (WebCore::WorkerContext::groupSettings):
     41        (WorkerContext):
     42        * workers/WorkerThread.cpp:
     43        (WebCore::WorkerThread::workerThread):
     44        * workers/WorkerThread.h:
     45        (WorkerThread):
     46
    1472012-07-12  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
    248
  • trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp

    r121742 r122463  
    101101    RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), 0);
    102102    WorkerContext* workerContext = static_cast<WorkerContext*>(context);
    103     GroupSettings* groupSettings = workerContext->thread()->groupSettings();
     103    const GroupSettings* groupSettings = workerContext->groupSettings();
    104104    m_backend->openFromWorker(name, request.get(), context->securityOrigin(), workerContext, groupSettings ? groupSettings->indexedDBDatabasePath() : String());
    105105    return request;
  • trunk/Source/WebCore/workers/DedicatedWorkerContext.cpp

    r104329 r122463  
    4242namespace WebCore {
    4343
    44 DedicatedWorkerContext::DedicatedWorkerContext(const KURL& url, const String& userAgent, DedicatedWorkerThread* thread, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
    45     : WorkerContext(url, userAgent, thread, contentSecurityPolicy, contentSecurityPolicyType)
     44DedicatedWorkerContext::DedicatedWorkerContext(const KURL& url, const String& userAgent, PassOwnPtr<GroupSettings> settings, DedicatedWorkerThread* thread, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
     45    : WorkerContext(url, userAgent, settings, thread, contentSecurityPolicy, contentSecurityPolicyType)
    4646{
    4747}
  • trunk/Source/WebCore/workers/DedicatedWorkerContext.h

    r104329 r122463  
    4545    public:
    4646        typedef WorkerContext Base;
    47         static PassRefPtr<DedicatedWorkerContext> create(const KURL& url, const String& userAgent, DedicatedWorkerThread* thread, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
     47        static PassRefPtr<DedicatedWorkerContext> create(const KURL& url, const String& userAgent, PassOwnPtr<GroupSettings> settings, DedicatedWorkerThread* thread, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
    4848        {
    49             return adoptRef(new DedicatedWorkerContext(url, userAgent, thread, contentSecurityPolicy, contentSecurityPolicyType));
     49            return adoptRef(new DedicatedWorkerContext(url, userAgent, settings, thread, contentSecurityPolicy, contentSecurityPolicyType));
    5050        }
    5151
     
    6767        DedicatedWorkerThread* thread();
    6868    private:
    69         DedicatedWorkerContext(const KURL&, const String& userAgent, DedicatedWorkerThread*, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
     69        DedicatedWorkerContext(const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, DedicatedWorkerThread*, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
    7070    };
    7171
  • trunk/Source/WebCore/workers/DedicatedWorkerThread.cpp

    r121742 r122463  
    5555}
    5656
    57 PassRefPtr<WorkerContext> DedicatedWorkerThread::createWorkerContext(const KURL& url, const String& userAgent, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
     57PassRefPtr<WorkerContext> DedicatedWorkerThread::createWorkerContext(const KURL& url, const String& userAgent, PassOwnPtr<GroupSettings> settings, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
    5858{
    59     return DedicatedWorkerContext::create(url, userAgent, this, contentSecurityPolicy, contentSecurityPolicyType);
     59    return DedicatedWorkerContext::create(url, userAgent, settings, this, contentSecurityPolicy, contentSecurityPolicyType);
    6060}
    6161
  • trunk/Source/WebCore/workers/DedicatedWorkerThread.h

    r121742 r122463  
    4747
    4848    protected:
    49         virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String& userAgent, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
     49        virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
    5050        virtual void runEventLoop();
    5151
  • trunk/Source/WebCore/workers/SharedWorkerContext.cpp

    r104803 r122463  
    5151}
    5252
    53 SharedWorkerContext::SharedWorkerContext(const String& name, const KURL& url, const String& userAgent, SharedWorkerThread* thread, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
    54     : WorkerContext(url, userAgent, thread, contentSecurityPolicy, contentSecurityPolicyType)
     53SharedWorkerContext::SharedWorkerContext(const String& name, const KURL& url, const String& userAgent, PassOwnPtr<GroupSettings> settings, SharedWorkerThread* thread, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
     54    : WorkerContext(url, userAgent, settings, thread, contentSecurityPolicy, contentSecurityPolicyType)
    5555    , m_name(name)
    5656{
  • trunk/Source/WebCore/workers/SharedWorkerContext.h

    r104803 r122463  
    4545    public:
    4646        typedef WorkerContext Base;
    47         static PassRefPtr<SharedWorkerContext> create(const String& name, const KURL& url, const String& userAgent, SharedWorkerThread* thread, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
     47        static PassRefPtr<SharedWorkerContext> create(const String& name, const KURL& url, const String& userAgent, PassOwnPtr<GroupSettings> settings, SharedWorkerThread* thread, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
    4848        {
    49             return adoptRef(new SharedWorkerContext(name, url, userAgent, thread, contentSecurityPolicy, contentSecurityPolicyType));
     49            return adoptRef(new SharedWorkerContext(name, url, userAgent, settings, thread, contentSecurityPolicy, contentSecurityPolicyType));
    5050        }
    5151        virtual ~SharedWorkerContext();
     
    6262        SharedWorkerThread* thread();
    6363    private:
    64         SharedWorkerContext(const String& name, const KURL&, const String&, SharedWorkerThread*, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
     64        SharedWorkerContext(const String& name, const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, SharedWorkerThread*, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
    6565
    6666        virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>);
  • trunk/Source/WebCore/workers/SharedWorkerThread.cpp

    r121742 r122463  
    5454}
    5555
    56 PassRefPtr<WorkerContext> SharedWorkerThread::createWorkerContext(const KURL& url, const String& userAgent, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
     56PassRefPtr<WorkerContext> SharedWorkerThread::createWorkerContext(const KURL& url, const String& userAgent, PassOwnPtr<GroupSettings> settings, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
    5757{
    58     return SharedWorkerContext::create(m_name, url, userAgent, this, contentSecurityPolicy, contentSecurityPolicyType);
     58    return SharedWorkerContext::create(m_name, url, userAgent, settings, this, contentSecurityPolicy, contentSecurityPolicyType);
    5959}
    6060
  • trunk/Source/WebCore/workers/SharedWorkerThread.h

    r121742 r122463  
    4444
    4545    protected:
    46         virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String&, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
     46        virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
    4747
    4848    private:
  • trunk/Source/WebCore/workers/WorkerContext.cpp

    r111969 r122463  
    8686};
    8787
    88 WorkerContext::WorkerContext(const KURL& url, const String& userAgent, WorkerThread* thread, const String& policy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
     88WorkerContext::WorkerContext(const KURL& url, const String& userAgent, PassOwnPtr<GroupSettings> settings, WorkerThread* thread, const String& policy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
    8989    : m_url(url)
    9090    , m_userAgent(userAgent)
     91    , m_groupSettings(settings)
    9192    , m_script(adoptPtr(new WorkerScriptController(this)))
    9293    , m_thread(thread)
  • trunk/Source/WebCore/workers/WorkerContext.h

    r111969 r122463  
    3434#include "EventNames.h"
    3535#include "EventTarget.h"
     36#include "GroupSettings.h"
    3637#include "ScriptExecutionContext.h"
    3738#include "WorkerEventQueue.h"
     
    6970        KURL completeURL(const String&) const;
    7071
     72        const GroupSettings* groupSettings() { return m_groupSettings.get(); }
    7173        virtual String userAgent(const KURL&) const;
    7274
     
    138140
    139141    protected:
    140         WorkerContext(const KURL&, const String&, WorkerThread*, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
     142        WorkerContext(const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, WorkerThread*, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
    141143
    142144        virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>);
     
    161163        KURL m_url;
    162164        String m_userAgent;
     165        OwnPtr<GroupSettings> m_groupSettings;
    163166
    164167        mutable RefPtr<WorkerLocation> m_location;
  • trunk/Source/WebCore/workers/WorkerThread.cpp

    r121742 r122463  
    147147    {
    148148        MutexLocker lock(m_threadCreationMutex);
    149         m_workerContext = createWorkerContext(m_startupData->m_scriptURL, m_startupData->m_userAgent, m_startupData->m_contentSecurityPolicy, m_startupData->m_contentSecurityPolicyType);
     149        m_workerContext = createWorkerContext(m_startupData->m_scriptURL, m_startupData->m_userAgent, m_startupData->m_groupSettings.release(), m_startupData->m_contentSecurityPolicy, m_startupData->m_contentSecurityPolicyType);
    150150
    151151        if (m_runLoop.terminated()) {
     
    194194}
    195195
    196 GroupSettings* WorkerThread::groupSettings()
    197 {
    198     return m_startupData->m_groupSettings.get();
    199 }
    200 
    201196class WorkerThreadShutdownFinishTask : public ScriptExecutionContext::Task {
    202197public:
  • trunk/Source/WebCore/workers/WorkerThread.h

    r121742 r122463  
    6363        // Number of active worker threads.
    6464        static unsigned workerThreadCount();
    65         GroupSettings* groupSettings();
    6665
    6766#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
     
    7473
    7574        // Factory method for creating a new worker context for the thread.
    76         virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String& userAgent, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType) = 0;
     75        virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType) = 0;
    7776
    7877        // Executes the event loop for the worker thread. Derived classes can override to perform actions before/after entering the event loop.
Note: See TracChangeset for help on using the changeset viewer.