Bug 193204 - Web Inspector: Remote inspector can crash if attempting to navigate inspector page
Summary: Web Inspector: Remote inspector can crash if attempting to navigate inspector...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-01-07 12:21 PST by Joseph Pecoraro
Modified: 2019-01-07 14:13 PST (History)
5 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (2.36 KB, patch)
2019-01-07 12:22 PST, Joseph Pecoraro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2019-01-07 12:21:18 PST
Remote inspector can crash if attempting to navigate inspector page

Steps to Reproduce:
1. Open a remote inspector
2. Inspect that inspector
3. In inspector² js> location.href = "http://apple.com"
  => Inspector crash

Crash:

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

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.apple.WebKit              	0x000000010e4f754b WebKit::WebPageProxy::loadRequest(WebCore::ResourceRequest&&, WebCore::ShouldOpenExternalURLsPolicy, API::Object*) + 37 (WebPageProxy.cpp:1068)
1   com.apple.WebKit              	0x000000010e572e4c -[WKInspectorViewController webView:decidePolicyForNavigationAction:decisionHandler:] + 281 (utility:898)
2   com.apple.WebKit              	0x000000010e494549 WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction(WebKit::WebPageProxy&, WTF::Ref<API::NavigationAction, WTF::DumbPtrTraits<API::NavigationAction> >&&, WTF::Ref<WebKit::WebFramePolicyListenerProxy, WTF::DumbPtrTraits<WebKit::WebFramePolicyListenerProxy> >&&, API::Object*) + 647
...
Comment 1 Joseph Pecoraro 2019-01-07 12:21:28 PST
<rdar://problem/45550428>
Comment 2 Joseph Pecoraro 2019-01-07 12:22:20 PST
Created attachment 358512 [details]
[PATCH] Proposed Fix
Comment 3 Devin Rousso 2019-01-07 13:45:26 PST
Comment on attachment 358512 [details]
[PATCH] Proposed Fix

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

rs=me, never a bad idea to add a nullptr check 😁

> Source/WebKit/UIProcess/mac/RemoteWebInspectorProxyMac.mm:88
> +    m_inspectorView = adoptNS([[WKInspectorViewController alloc] initWithInspectedPage:nullptr]);

Just for my knowledge, is it preferred to use `nil` or `nullptr` in ObjC code?
Is `nullptr` preferred here because the value expected by `initWithInspectedPage` is a `WebPageProxy`, which is a C++ object, or am I just overthinking things?
Comment 4 Joseph Pecoraro 2019-01-07 13:47:45 PST
Comment on attachment 358512 [details]
[PATCH] Proposed Fix

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

>> Source/WebKit/UIProcess/mac/RemoteWebInspectorProxyMac.mm:88
>> +    m_inspectorView = adoptNS([[WKInspectorViewController alloc] initWithInspectedPage:nullptr]);
> 
> Just for my knowledge, is it preferred to use `nil` or `nullptr` in ObjC code?
> Is `nullptr` preferred here because the value expected by `initWithInspectedPage` is a `WebPageProxy`, which is a C++ object, or am I just overthinking things?

Using nil/nullptr and friends just like where to place the "*", the type is what matters:

    0 - never
    NULL - C type
    nullptr - C++ type
    nil - ObjC type
    Nil - ObjC Class type

I think that covers all the various cases.
Comment 5 WebKit Commit Bot 2019-01-07 14:13:37 PST
Comment on attachment 358512 [details]
[PATCH] Proposed Fix

Clearing flags on attachment: 358512

Committed r239697: <https://trac.webkit.org/changeset/239697>
Comment 6 WebKit Commit Bot 2019-01-07 14:13:38 PST
All reviewed patches have been landed.  Closing bug.