Bug 149484

Summary: [WK1] Null dereference loading Blink layout test editing/input/text-input-controller-no-editable-no-crash.html
Product: WebKit Reporter: Jon Honeycutt <jhoneycutt>
Component: HTML EditingAssignee: Jiewen Tan <jiewen_tan>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, commit-queue, jiewen_tan, webkit-bug-importer
Priority: P2 Keywords: BlinkMergeCandidate, HasReduction, InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
crashing test
none
Patch
none
Patch
darin: review+
Patch for committing none

Description Jon Honeycutt 2015-09-22 16:42:37 PDT
Created attachment 261778 [details]
crashing test

Null dereference loading Blink layout test editing/input/text-input-controller-no-editable-no-crash.html in WK1.

Test added in https://codereview.chromium.org/1122593004.


Stack trace:

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

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000020

Application Specific Information:
CRASHING TEST: temp-tests/editing/input/text-input-controller-no-editable-no-crash.html
This process is running with libgmalloc.dylib (GuardMalloc) which may have forced the crash due to a memory access error.
 

Global Trace Buffer (reverse chronological seconds):
46.798174    CFNetwork                 	0x00007fff88d445cd Creating default cookie storage with process/bundle identifier
46.798174    CFNetwork                 	0x00007fff88d44565 Faulting in CFHTTPCookieStorage singleton
46.798190    CFNetwork                 	0x00007fff88ba7b49 Faulting in NSHTTPCookieStorage singleton

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.apple.WebCore             	0x0000000111bf2213 WebCore::TextIterator::rangeFromLocationAndLength(WebCore::ContainerNode*, int, int, bool) + 35 (Node.h:401)
1   com.apple.WebKitLegacy        	0x00000001133bb83d -[WebFrame(WebInternal) _convertToDOMRange:] + 125 (RefPtr.h:61)
2   com.apple.WebKitLegacy        	0x00000001133bb8bc -[WebFrame(WebInternal) _convertNSRangeToDOMRange:] + 44 (PassRefPtr.h:63)
3   com.apple.WebKitLegacy        	0x00000001133ec010 -[WebHTMLView(WebNSTextInputSupport) firstRectForCharacterRange:] + 112 (WebHTMLView.mm:6140)
4   DumpRenderTree                	0x000000010f5a68f0 -[TextInputController firstRectForCharactersFrom:length:] + 74 (TextInputController.m:417)
5   com.apple.CoreFoundation      	0x00007fff9499d87c __invoking___ + 140
6   com.apple.CoreFoundation      	0x00007fff9499d6ce -[NSInvocation invoke] + 286
7   com.apple.WebCore             	0x000000011176b3fe JSC::Bindings::ObjcInstance::invokeObjcMethod(JSC::ExecState*, JSC::Bindings::ObjcMethod*) + 1070 (objc_instance.mm:326)
8   com.apple.WebCore             	0x00000001119c9d42 JSC::callRuntimeMethod(JSC::ExecState*) + 306 (runtime_method.cpp:101)
9   com.apple.JavaScriptCore      	0x000000010fbf6e9a JSC::LLInt::setUpCall(JSC::ExecState*, JSC::Instruction*, JSC::CodeSpecializationKind, JSC::JSValue, JSC::LLIntCallLinkInfo*) + 538 (LLIntSlowPaths.cpp:1084)
10  com.apple.JavaScriptCore      	0x000000010fbfd764 llint_entry + 22685
11  com.apple.JavaScriptCore      	0x000000010fbfd76f llint_entry + 22696
12  com.apple.JavaScriptCore      	0x000000010fbf7ce4 vmEntryToJavaScript + 299
13  com.apple.JavaScriptCore      	0x000000010fab82d9 JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 169 (JITCode.cpp:82)
14  com.apple.JavaScriptCore      	0x000000010fa9ed12 JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 450 (Interpreter.cpp:1008)
15  com.apple.JavaScriptCore      	0x000000010f76a8b7 JSC::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&, WTF::NakedPtr<JSC::Exception>&) + 71 (MarkedBlock.h:241)
16  com.apple.WebCore             	0x00000001113e5fa4 WebCore::JSEventListener::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) + 996 (JSMainThreadExecState.h:56)
17  com.apple.WebCore             	0x000000011104c4db WebCore::EventTarget::fireEventListeners(WebCore::Event*, WebCore::EventTargetData*, WTF::Vector<WebCore::RegisteredEventListener, 1ul, WTF::CrashOnOverflow, 16ul>&) + 635 (InspectorInstrumentation.h:285)
18  com.apple.WebCore             	0x000000011104c1a0 WebCore::EventTarget::fireEventListeners(WebCore::Event*) + 224 (EventTarget.cpp:208)
19  com.apple.WebCore             	0x0000000110fd8bf4 WebCore::DOMWindow::dispatchEvent(WTF::PassRefPtr<WebCore::Event>, WTF::PassRefPtr<WebCore::EventTarget>) + 260 (DOMWindow.cpp:1900)
20  com.apple.WebCore             	0x0000000110fde30b WebCore::DOMWindow::dispatchLoadEvent() + 347 (StdLibExtras.h:366)
21  com.apple.WebCore             	0x0000000110f41294 WebCore::Document::implicitClose() + 324 (Document.cpp:4077)
22  com.apple.WebCore             	0x00000001110ce003 WebCore::FrameLoader::checkCompleted() + 275 (FrameLoader.cpp:839)
23  com.apple.WebCore             	0x00000001110cc95b WebCore::FrameLoader::finishedParsing() + 123 (FrameLoader.cpp:760)
24  com.apple.WebCore             	0x0000000110f4c281 WebCore::Document::finishedParsing() + 417 (Frame.h:377)
25  com.apple.WebCore             	0x0000000111178e05 WebCore::HTMLDocumentParser::prepareToStopParsing() + 165 (RefCounted.h:99)
26  com.apple.WebCore             	0x0000000110f7c69a WebCore::DocumentWriter::end() + 58 (StdLibExtras.h:366)
27  com.apple.WebCore             	0x0000000110f649ec WebCore::DocumentLoader::finishedLoading(double) + 268 (ResourceErrorBase.h:42)
28  com.apple.WebCore             	0x0000000110d95179 WebCore::CachedResource::checkNotify() + 153 (CachedResourceClientWalker.h:51)
29  com.apple.WebCore             	0x0000000110d91433 WebCore::CachedRawResource::finishLoading(WebCore::SharedBuffer*) + 227 (CachedRawResource.cpp:104)
30  com.apple.WebCore             	0x0000000111b0c501 WebCore::SubresourceLoader::didFinishLoading(double) + 1153 (ResourceLoader.h:154)
31  com.apple.CFNetwork           	0x00007fff88c5c622 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 69
32  com.apple.CFNetwork           	0x00007fff88c5c49e -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 233
33  com.apple.CFNetwork           	0x00007fff88c5c3a3 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 48
34  com.apple.CFNetwork           	0x00007fff88c5d3b4 ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 104
35  com.apple.CFNetwork           	0x00007fff88d3ad5f ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 100
36  libdispatch.dylib             	0x00007fff96096331 _dispatch_client_callout + 8
37  libdispatch.dylib             	0x00007fff960ac9ad _dispatch_block_invoke + 474
38  com.apple.CFNetwork           	0x00007fff88bb67f4 RunloopBlockContext::_invoke_block(void const*, void*) + 24
39  com.apple.CoreFoundation      	0x00007fff949aeff4 CFArrayApplyFunction + 68
40  com.apple.CFNetwork           	0x00007fff88bb66ed RunloopBlockContext::perform() + 137
41  com.apple.CFNetwork           	0x00007fff88bb64c4 MultiplexerSource::perform() + 282
42  com.apple.CFNetwork           	0x00007fff88bb62e6 MultiplexerSource::_perform(void*) + 72
43  com.apple.CoreFoundation      	0x00007fff949e2c01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
44  com.apple.CoreFoundation      	0x00007fff949d4b1c __CFRunLoopDoSources0 + 556
45  com.apple.CoreFoundation      	0x00007fff949d403f __CFRunLoopRun + 927
46  com.apple.CoreFoundation      	0x00007fff949d3a38 CFRunLoopRunSpecific + 296
47  DumpRenderTree                	0x000000010f58ceb3 runTest(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 2146 (DumpRenderTree.mm:2031)
48  DumpRenderTree                	0x000000010f58c41a dumpRenderTree(int, char const**) + 2928 (DumpRenderTree.mm:1288)
49  DumpRenderTree                	0x000000010f58da2a DumpRenderTreeMain(int, char const**) + 1471 (DumpRenderTree.mm:1424)
50  libdyld.dylib                 	0x00007fff93aa15ad start + 1
Comment 1 Radar WebKit Bug Importer 2015-09-22 16:43:10 PDT
<rdar://problem/22811338>
Comment 2 Jiewen Tan 2015-11-02 14:17:46 PST
Created attachment 264626 [details]
Patch
Comment 3 Jiewen Tan 2015-11-02 14:20:02 PST
Created attachment 264627 [details]
Patch
Comment 4 Darin Adler 2015-11-02 22:28:08 PST
Comment on attachment 264627 [details]
Patch

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

> Source/WebKit/mac/WebView/WebFrame.mm:811
> +    if (!_private->coreFrame->selection().rootEditableElementOrDocumentElement())
> +        return 0;

This is such a long expression, I suggest putting the result into a local variable.

This is an Objective-C object pointer, so I suggest returning nil, not 0.
Comment 5 Jiewen Tan 2015-11-03 14:06:29 PST
Created attachment 264721 [details]
Patch for committing
Comment 6 WebKit Commit Bot 2015-11-03 18:48:43 PST
Comment on attachment 264721 [details]
Patch for committing

Clearing flags on attachment: 264721

Committed r192007: <http://trac.webkit.org/changeset/192007>