Bug 108636 - Creating a WebInspector.ContextMenu without an event crashes WebCore when calling .show()
Summary: Creating a WebInspector.ContextMenu without an event crashes WebCore when cal...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Antoine Quint
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2013-02-01 07:31 PST by Antoine Quint
Modified: 2013-02-02 05:56 PST (History)
10 users (show)

See Also:


Attachments
Patch (1.51 KB, patch)
2013-02-01 07:33 PST, Antoine Quint
no flags Details | Formatted Diff | Diff
Patch (2.16 KB, patch)
2013-02-01 09:37 PST, Antoine Quint
no flags Details | Formatted Diff | Diff
Patch (2.30 KB, patch)
2013-02-02 05:06 PST, Antoine Quint
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antoine Quint 2013-02-01 07:31:07 PST
Creating a WebInspector.ContextMenu without an event crashes WebCore when calling .show()
Comment 1 Antoine Quint 2013-02-01 07:33:18 PST
Created attachment 186044 [details]
Patch
Comment 2 Dean Jackson 2013-02-01 07:34:48 PST
Comment on attachment 186044 [details]
Patch

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

> Source/WebCore/ChangeLog:10
> +        No new tests (OOPS!).

At least mention why there are no tests, or remove this line.
Comment 3 Radar WebKit Bug Importer 2013-02-01 07:35:44 PST
<rdar://problem/13133613>
Comment 4 Pavel Feldman 2013-02-01 07:58:24 PST
Comment on attachment 186044 [details]
Patch

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

> Source/WebCore/page/ContextMenuController.cpp:145
> +    if (!event || !event->isMouseEvent())

Do you want to add an assertion here instead?
Comment 5 Antoine Quint 2013-02-01 09:12:40 PST
(In reply to comment #4)
> (From update of attachment 186044 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=186044&action=review
> 
> > Source/WebCore/page/ContextMenuController.cpp:145
> > +    if (!event || !event->isMouseEvent())
> 
> Do you want to add an assertion here instead?

You mean *also* an assert before the early return?
Comment 6 Pavel Feldman 2013-02-01 09:21:33 PST
Comment on attachment 186044 [details]
Patch

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

>>> Source/WebCore/page/ContextMenuController.cpp:145
>>> +    if (!event || !event->isMouseEvent())
>> 
>> Do you want to add an assertion here instead?
> 
> You mean *also* an assert before the early return?

I meant assertion + a check on the call site. One obviously needs an event for creating this menu.
Comment 7 Antoine Quint 2013-02-01 09:37:38 PST
Created attachment 186066 [details]
Patch
Comment 8 Pavel Feldman 2013-02-01 09:41:25 PST
Comment on attachment 186066 [details]
Patch

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

> Source/WebCore/page/ContextMenuController.cpp:111
> +    if (!event)

When does this happen?

> Source/WebCore/page/ContextMenuController.cpp:130
> +    if (!event)

When does this happen?
Comment 9 Antoine Quint 2013-02-01 09:47:11 PST
(In reply to comment #8)
> (From update of attachment 186066 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=186066&action=review
> 
> > Source/WebCore/page/ContextMenuController.cpp:111
> > +    if (!event)
> 
> When does this happen?

I'm not sure when it would, but I understood from your previous comment you wanted all call sites to ContextMenuController::createContextMenu() guarded.

> > Source/WebCore/page/ContextMenuController.cpp:130
> > +    if (!event)
> 
> When does this happen?

This would happen if you call InspectorFrontendHost.showContextMenu() from the front-end JS code without an event. This was how I originally found the issue.
Comment 10 Antoine Quint 2013-02-01 09:50:45 PST
(In reply to comment #9)
> (In reply to comment #8)
> > (From update of attachment 186066 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=186066&action=review
> > 
> > > Source/WebCore/page/ContextMenuController.cpp:111
> > > +    if (!event)
> > 
> > When does this happen?
> 
> I'm not sure when it would, but I understood from your previous comment you wanted all call sites to ContextMenuController::createContextMenu() guarded.

I guess you meant the actual original call site in the JS code. In this case, WebInspector.ContextMenu.prototype.show().
Comment 11 Pavel Feldman 2013-02-02 04:04:27 PST
Comment on attachment 186066 [details]
Patch

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

>>>> Source/WebCore/page/ContextMenuController.cpp:111
>>>> +    if (!event)
>>> 
>>> When does this happen?
>> 
>> I'm not sure when it would, but I understood from your previous comment you wanted all call sites to ContextMenuController::createContextMenu() guarded.
> 
> I guess you meant the actual original call site in the JS code. In this case, WebInspector.ContextMenu.prototype.show().

Oh, I meant to place the checks into the call sites that operate nullable event pointers. This one does not.

>>> Source/WebCore/page/ContextMenuController.cpp:130
>>> +    if (!event)
>> 
>> When does this happen?
> 
> This would happen if you call InspectorFrontendHost.showContextMenu() from the front-end JS code without an event. This was how I originally found the issue.

You probably want to move this check into the call site (InspectorFrontendHost::showContextMenu) then. That way you clearly separate contexts with nullable event pointers from the ones that rely upon their existence.
Comment 12 Antoine Quint 2013-02-02 05:06:06 PST
Created attachment 186224 [details]
Patch
Comment 13 WebKit Review Bot 2013-02-02 05:16:54 PST
Comment on attachment 186224 [details]
Patch

Rejecting attachment 186224 [details] from commit-queue.

graouts@apple.com does not have committer permissions according to http://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/common/config/committers.py.

- If you do not have committer rights please read http://webkit.org/coding/contributing.html for instructions on how to use bugzilla flags.

- If you have committer rights please correct the error in Tools/Scripts/webkitpy/common/config/committers.py by adding yourself to the file (no review needed).  The commit-queue restarts itself every 2 hours.  After restart the commit-queue will correctly respect your committer rights.
Comment 14 WebKit Review Bot 2013-02-02 05:56:34 PST
Comment on attachment 186224 [details]
Patch

Clearing flags on attachment: 186224

Committed r141692: <http://trac.webkit.org/changeset/141692>
Comment 15 WebKit Review Bot 2013-02-02 05:56:39 PST
All reviewed patches have been landed.  Closing bug.