Bug 93521 - ASSERT(m_workerContext->isSharedWorkerContext()) in WorkerScriptController::initScript() when providing Content Security Policy to dedicated worker.
Summary: ASSERT(m_workerContext->isSharedWorkerContext()) in WorkerScriptController::i...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Thomas Sepez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-08 14:18 PDT by Thomas Sepez
Modified: 2012-08-08 17:16 PDT (History)
2 users (show)

See Also:


Attachments
Test case (1.51 KB, patch)
2012-08-08 14:24 PDT, Thomas Sepez
no flags Details | Formatted Diff | Diff
Proposed patch. (13.21 KB, patch)
2012-08-08 16:13 PDT, Thomas Sepez
no flags Details | Formatted Diff | Diff
Patch, add assert. (13.59 KB, patch)
2012-08-08 16:55 PDT, Thomas Sepez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Sepez 2012-08-08 14:18:10 PDT
The assert is triggered because the m_workerContext is not a dedicated worker and is also not a shared worker.  Its essentially still the base class since the construction of the derived class has not yet finished -- a C++ gotcha as far as I know.

(gdb) i stack
#0  0x00000001022608e7 in WebCore::WorkerScriptController::initScript (this=0x108e2cb60) at /Volumes/MacintoshHD2/w9/WebKit/Source/WebCore/bindings/js/WorkerScriptController.cpp:98
#1  0x0000000102729ef6 in WebCore::WorkerScriptController::initScriptIfNeeded (this=0x108e2cb60) at WorkerScriptController.h:86
#2  0x0000000102260bd1 in WebCore::WorkerScriptController::disableEval (this=0x108e2cb60) at /Volumes/MacintoshHD2/w9/WebKit/Source/WebCore/bindings/js/WorkerScriptController.cpp:193
#3  0x000000010223b732 in WebCore::WorkerContext::disableEval (this=0x108e3f160) at /Volumes/MacintoshHD2/w9/WebKit/Source/WebCore/workers/WorkerContext.cpp:148
#4  0x0000000101a04b35 in WebCore::ContentSecurityPolicy::didReceiveHeader (this=0x109b1b1d0, header=@0x12cb4f898, type=WebCore::ContentSecurityPolicy::EnforcePolicy) at /Volumes/MacintoshHD2/w9/WebKit/Source/WebCore/page/ContentSecurityPolicy.cpp:1072
#5  0x000000010223c609 in WebCore::WorkerContext::WorkerContext (this=0x108e3f160, url=@0x12cb4f840, userAgent=@0x12cb4f878, settings=@0x135180c50, thread=0x12cb4eb00, policy=@0x12cb4f898, contentSecurityPolicyType=WebCore::ContentSecurityPolicy::EnforcePolicy) at /Volumes/MacintoshHD2/w9/WebKit/Source/WebCore/workers/WorkerContext.cpp:102
#6  0x0000000101bb7fee in WebCore::DedicatedWorkerContext::DedicatedWorkerContext (this=0x108e3f160, url=@0x12cb4f840, userAgent=@0x12cb4f878, settings=@0x135180cc0, thread=0x12cb4eb00, contentSecurityPolicy=@0x12cb4f898, contentSecurityPolicyType=WebCore::ContentSecurityPolicy::EnforcePolicy) at /Volumes/MacintoshHD2/w9/WebKit/Source/WebCore/workers/DedicatedWorkerContext.cpp:45
#7  0x0000000101bb9a2e in WebCore::DedicatedWorkerContext::create (url=@0x12cb4f840, userAgent=@0x12cb4f878, settings=@0x135180d50, thread=0x12cb4eb00, contentSecurityPolicy=@0x12cb4f898, contentSecurityPolicyType=WebCore::ContentSecurityPolicy::EnforcePolicy) at DedicatedWorkerContext.h:49
#8  0x0000000101bb94df in WebCore::DedicatedWorkerThread::createWorkerContext (this=0x12cb4eb00, url=@0x12cb4f840, userAgent=@0x12cb4f878, settings=@0x135180e20, contentSecurityPolicy=@0x12cb4f898, contentSecurityPolicyType=WebCore::ContentSecurityPolicy::EnforcePolicy) at /Volumes/MacintoshHD2/w9/WebKit/Source/WebCore/workers/DedicatedWorkerThread.cpp:59
#9  0x0000000102276072 in WebCore::WorkerThread::workerThread (this=0x12cb4eb00) at /Volumes/MacintoshHD2/w9/WebKit/Source/WebCore/workers/WorkerThread.cpp:149
#10 0x000000010227627b in WebCore::WorkerThread::workerThreadStart (thread=0x12cb4eb00) at /Volumes/MacintoshHD2/w9/WebKit/Source/WebCore/workers/WorkerThread.cpp:142
#11 0x00000001005aa76c in WTF::threadEntryPoint (contextData=0x12cb50730) at /Volumes/MacintoshHD2/w9/WebKit/Source/WTF/wtf/Threading.cpp:69
#12 0x00000001005ab34f in WTF::wtfThreadEntryPoint (param=0x12cb4c930) at /Volumes/MacintoshHD2/w9/WebKit/Source/WTF/wtf/ThreadingPthreads.cpp:157
#13 0x00007fff82cbafd6 in _pthread_start ()
#14 0x00007fff82cbae89 in thread_start ()

The test case will be attached shortly, though there are other issues which prevent it from passing
Comment 1 Thomas Sepez 2012-08-08 14:24:40 PDT
Created attachment 157294 [details]
Test case
Comment 2 Thomas Sepez 2012-08-08 14:27:29 PDT
Added testcase, derived from work on  https://bugs.webkit.org/show_bug.cgi?id=93392 hence the naming though for the purposes of this bug, the settimeout part doesn't get reached and is of no concern.
Comment 3 Thomas Sepez 2012-08-08 16:13:58 PDT
Created attachment 157323 [details]
Proposed patch.
Comment 4 Adam Barth 2012-08-08 16:17:50 PDT
Comment on attachment 157323 [details]
Proposed patch.

Can we add an ASSERT to the base class to make sure applyContentSecurityPolicyFromString is called?
Comment 5 Thomas Sepez 2012-08-08 16:55:44 PDT
Created attachment 157336 [details]
Patch, add assert.

Sure.  We'll postpone the creation of the CSP object until the new method is called, then we'll assert that there's a CSP.
Comment 6 Adam Barth 2012-08-08 17:02:35 PDT
Comment on attachment 157336 [details]
Patch, add assert.

Rockin'
Comment 7 WebKit Review Bot 2012-08-08 17:16:54 PDT
Comment on attachment 157336 [details]
Patch, add assert.

Clearing flags on attachment: 157336

Committed r125120: <http://trac.webkit.org/changeset/125120>
Comment 8 WebKit Review Bot 2012-08-08 17:16:57 PDT
All reviewed patches have been landed.  Closing bug.