Bug 149300

Summary: Null dereference loading Blink layout test editing/style/apply-style-crash2.html
Product: WebKit Reporter: Jon Honeycutt <jhoneycutt>
Component: HTML EditingAssignee: Jiewen Tan <jiewen_tan>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, commit-queue, jiewen_tan, rniwa, webkit-bug-importer
Priority: P2 Keywords: BlinkMergeCandidate, HasReduction, InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
crashing test
none
crashing test 2
none
Patch
none
Patch
none
Patch none

Description Jon Honeycutt 2015-09-17 14:58:37 PDT
Created attachment 261435 [details]
crashing test

Null dereference loading Blink layout test editing/style/apply-style-crash2.html.

Stack trace:

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000014
Exception Note:        EXC_CORPSE_NOTIFY

VM Regions Near 0x14:
--> 
    __TEXT                 000000010a350000-000000010a352000 [    8K] r-x/rwx SM=COW  /Users/USER/*/WebKit.framework/Versions/A/XPCServices/com.apple.WebKit.WebContent.Development.xpc/Contents/MacOS/com.apple.WebKit.WebContent.Development

Application Specific Information:
CRASHING TEST: temp-tests/editing/style/apply-style-crash2.html

Global Trace Buffer (reverse chronological seconds):
18446744062.318451 CFNetwork                 	0x00007fff88d43b97 Explicitly setting CF cookie storage singleton
18446744062.318817 CFNetwork                 	0x00007fff88d8f211 Explicitly setting cookie storage singleton

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.apple.WebCore             	0x0000000112091db5 WebCore::ApplyStyleCommand::applyRelativeFontStyleChange(WebCore::EditingStyle*) + 2261 (Node.h:638)
1   com.apple.WebCore             	0x00000001120900ee WebCore::ApplyStyleCommand::doApply() + 158 (RefPtr.h:61)
2   com.apple.WebCore             	0x0000000112144216 WebCore::CompositeEditCommand::apply() + 102 (ScopedEventQueue.h:71)
3   com.apple.WebCore             	0x0000000112367bfb WebCore::Editor::applyStyle(WTF::RefPtr<WebCore::EditingStyle>&&, WebCore::EditAction) + 107 (StdLibExtras.h:366)
4   com.apple.WebCore             	0x000000011237a2a3 WebCore::applyCommandToFrame(WebCore::Frame&, WebCore::EditorCommandSource, WebCore::EditAction, WTF::Ref<WebCore::EditingStyle>&&) + 51 (StdLibExtras.h:366)
5   com.apple.WebCore             	0x000000011237a22f WebCore::executeApplyStyle(WebCore::Frame&, WebCore::EditorCommandSource, WebCore::EditAction, WebCore::CSSPropertyID, WTF::String const&) + 79 (EditorCommand.cpp:129)
6   com.apple.WebCore             	0x0000000112376876 WebCore::Editor::Command::execute(WTF::String const&, WebCore::Event*) const + 182 (EditorCommand.cpp:1704)
7   com.apple.WebCore             	0x00000001122afc36 WebCore::Document::execCommand(WTF::String const&, bool, WTF::String const&) + 214 (Document.cpp:4666)
8   com.apple.WebCore             	0x00000001126c6074 WebCore::jsDocumentPrototypeFunctionExecCommand(JSC::ExecState*) + 420 (JSCJSValue.h:499)
9   ???                           	0x0000520338c01028 0 + 90173790490664
10  com.apple.JavaScriptCore      	0x0000000111a2276f llint_entry + 22696
11  com.apple.JavaScriptCore      	0x0000000111a1cce4 vmEntryToJavaScript + 299
12  com.apple.JavaScriptCore      	0x00000001118dd2d9 JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 169 (JITCode.cpp:82)
13  com.apple.JavaScriptCore      	0x00000001118c3a10 JSC::Interpreter::execute(JSC::ProgramExecutable*, JSC::ExecState*, JSC::JSObject*) + 10448 (Interpreter.cpp:945)
14  com.apple.JavaScriptCore      	0x00000001115d64c5 JSC::evaluate(JSC::ExecState*, JSC::SourceCode const&, JSC::JSValue, WTF::NakedPtr<JSC::Exception>&) + 469 (Completion.cpp:104)
15  com.apple.WebCore             	0x0000000112d398ec WebCore::ScriptController::evaluateInWorld(WebCore::ScriptSourceCode const&, WebCore::DOMWrapperWorld&) + 284 (JSMainThreadExecState.h:62)
16  com.apple.WebCore             	0x0000000112d39b29 WebCore::ScriptController::evaluate(WebCore::ScriptSourceCode const&) + 41 (ScriptController.cpp:180)
17  com.apple.WebCore             	0x0000000112d3faac WebCore::ScriptElement::executeScript(WebCore::ScriptSourceCode const&) + 316 (ScriptElement.cpp:309)
18  com.apple.WebCore             	0x0000000112d3e756 WebCore::ScriptElement::prepareScript(WTF::TextPosition const&, WebCore::ScriptElement::LegacyTypeSupport) + 1046 (StdLibExtras.h:366)
19  com.apple.WebCore             	0x000000011253b5eb WebCore::HTMLScriptRunner::runScript(WebCore::Element*, WTF::TextPosition const&) + 347 (ScriptElement.h:58)
20  com.apple.WebCore             	0x000000011253b440 WebCore::HTMLScriptRunner::execute(WTF::PassRefPtr<WebCore::Element>, WTF::TextPosition const&) + 48 (HTMLScriptRunner.cpp:191)
21  com.apple.WebCore             	0x00000001124de466 WebCore::HTMLDocumentParser::runScriptsForPausedTreeBuilder() + 86 (StdLibExtras.h:366)
22  com.apple.WebCore             	0x00000001124de52d WebCore::HTMLDocumentParser::canTakeNextToken(WebCore::HTMLDocumentParser::SynchronousMode, WebCore::PumpSession&) + 93 (HTMLDocumentParser.cpp:214)
23  com.apple.WebCore             	0x00000001124de0c3 WebCore::HTMLDocumentParser::pumpTokenizer(WebCore::HTMLDocumentParser::SynchronousMode) + 595 (HTMLDocumentParser.cpp:259)
24  com.apple.WebCore             	0x00000001124deddd WebCore::HTMLDocumentParser::append(WTF::PassRefPtr<WTF::StringImpl>) + 669 (DocumentParser.h:71)
25  com.apple.WebCore             	0x000000011228161c WebCore::DecodedDataDocumentParser::flush(WebCore::DocumentWriter&) + 92 (StdLibExtras.h:366)
26  com.apple.WebCore             	0x00000001122e168b WebCore::DocumentWriter::end() + 43 (RefPtr.h:71)
27  com.apple.WebCore             	0x00000001122c99ec WebCore::DocumentLoader::finishedLoading(double) + 268 (ResourceErrorBase.h:42)
28  com.apple.WebCore             	0x00000001120fa179 WebCore::CachedResource::checkNotify() + 153 (CachedResourceClientWalker.h:51)
29  com.apple.WebCore             	0x00000001120f6433 WebCore::CachedRawResource::finishLoading(WebCore::SharedBuffer*) + 227 (CachedRawResource.cpp:104)
30  com.apple.WebCore             	0x0000000112e71501 WebCore::SubresourceLoader::didFinishLoading(double) + 1153 (ResourceLoader.h:154)
31  com.apple.WebKit              	0x00000001109b798d WebKit::WebResourceLoader::didReceiveWebResourceLoaderMessage(IPC::Connection&, IPC::MessageDecoder&) + 561 (HandleMessage.h:16)
32  com.apple.WebKit              	0x00000001107911f1 IPC::Connection::dispatchMessage(std::__1::unique_ptr<IPC::MessageDecoder, std::__1::default_delete<IPC::MessageDecoder> >) + 127 (memory:2636)
33  com.apple.WebKit              	0x0000000110793b4a IPC::Connection::dispatchOneMessage() + 126 (memory:2656)
34  com.apple.JavaScriptCore      	0x0000000111bd5985 WTF::RunLoop::performWork() + 437 (functional:1742)
35  com.apple.JavaScriptCore      	0x0000000111bd5d32 WTF::RunLoop::performWork(void*) + 34 (RunLoopCF.cpp:39)
36  com.apple.CoreFoundation      	0x00007fff949e2c01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
37  com.apple.CoreFoundation      	0x00007fff949d4b1c __CFRunLoopDoSources0 + 556
38  com.apple.CoreFoundation      	0x00007fff949d403f __CFRunLoopRun + 927
39  com.apple.CoreFoundation      	0x00007fff949d3a38 CFRunLoopRunSpecific + 296
40  com.apple.HIToolbox           	0x00007fff88e673bd RunCurrentEventLoopInMode + 235
41  com.apple.HIToolbox           	0x00007fff88e67153 ReceiveNextEventCommon + 432
42  com.apple.HIToolbox           	0x00007fff88e66f93 _BlockUntilNextEventMatchingListInModeWithFilter + 71
43  com.apple.AppKit              	0x00007fff870b81e7 _DPSNextEvent + 1076
44  com.apple.AppKit              	0x00007fff8748490d -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454
45  com.apple.AppKit              	0x00007fff870ae0b8 -[NSApplication run] + 682
46  com.apple.AppKit              	0x00007fff87030396 NSApplicationMain + 1176
47  libxpc.dylib                  	0x00007fff8c70ff70 _xpc_objc_main + 793
48  libxpc.dylib                  	0x00007fff8c7116bf xpc_main + 494
49  com.apple.WebKit.WebContent.Development	0x000000010a351424 main + 409 (XPCServiceMain.Development.mm:187)
50  libdyld.dylib                 	0x00007fff93aa15ad start + 1
Comment 1 Radar WebKit Bug Importer 2015-09-17 14:58:56 PDT
<rdar://problem/22747046>
Comment 2 Jon Honeycutt 2015-09-17 16:46:08 PDT
Created attachment 261456 [details]
crashing test 2
Comment 3 Jiewen Tan 2015-10-02 16:35:54 PDT
Created attachment 262362 [details]
Patch
Comment 4 Jiewen Tan 2015-10-05 17:05:59 PDT
Created attachment 262482 [details]
Patch
Comment 5 Chris Dumez 2015-10-05 18:22:37 PDT
Comment on attachment 262482 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=262482&action=review

r=me with comments

> Source/WebCore/ChangeLog:10
> +        https://codereview.chromium.org/177093016

ahah I wrote that one.

> Source/WebCore/editing/ApplyStyleCommand.cpp:351
>      Node *beyondEnd;

Star on wrong side.

> Source/WebCore/editing/ApplyStyleCommand.cpp:377
> +    for (Node *node = startNode; node != beyondEnd; node = NodeTraversal::next(*node)) {

Star on wrong side

> Source/WebCore/editing/ApplyStyleCommand.cpp:385
>      Node* lastStyledNode = 0;

= nullptr;

> LayoutTests/editing/style/apply-style-crash3.html:12
> +    testRunner.dumpAsText();

This is not needed as this is the default with js-test.

> LayoutTests/editing/style/apply-style-crash3.html:13
> +    testRunner.waitUntilDone();

I don't think this test needs to be asynchronous so I believe you can drop this as well.

> LayoutTests/editing/style/apply-style-crash3.html:34
> +    testRunner.notifyDone();

I don't believe the test needs to be async so this is likely not needed.
Comment 6 Chris Dumez 2015-10-05 18:23:16 PDT
Comment on attachment 262482 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=262482&action=review

> Source/WebCore/ChangeLog:9
> +        This is a merge of Blink r167845 and r194944,

as for the previous patch, I would use a ':' at the end instead of a ','.
Comment 7 Jiewen Tan 2015-10-06 11:49:39 PDT
Created attachment 262532 [details]
Patch
Comment 8 WebKit Commit Bot 2015-10-06 12:48:55 PDT
Comment on attachment 262532 [details]
Patch

Clearing flags on attachment: 262532

Committed r190634: <http://trac.webkit.org/changeset/190634>
Comment 9 WebKit Commit Bot 2015-10-06 12:49:00 PDT
All reviewed patches have been landed.  Closing bug.