Bug 70535 - WK2 - Crash deref'ing a null context menu
Summary: WK2 - Crash deref'ing a null context menu
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Brady Eidson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2011-10-20 12:19 PDT by Brady Eidson
Modified: 2011-10-20 12:33 PDT (History)
1 user (show)

See Also:


Attachments
Patch v1 - s/assert/early return/ (1.48 KB, patch)
2011-10-20 12:26 PDT, Brady Eidson
darin: review+
beidson: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brady Eidson 2011-10-20 12:19:54 PDT
WK2 - Crash deref'ing a null context menu

In rare cases WebPage::didSelectItemFromActiveContextMenu in the WebProcess can be called without an active context menu, leading to a null deref.

We have an ASSERT in this function but no one has noticed (or reported...) this in debug builds.

Replacing the ASSERT with an early return will safely plug the crash.

In radar as <rdar://problem/9412849>
Comment 1 Brady Eidson 2011-10-20 12:26:50 PDT
Created attachment 111826 [details]
Patch v1 - s/assert/early return/
Comment 2 Adam Roben (:aroben) 2011-10-20 12:30:11 PDT
Comment on attachment 111826 [details]
Patch v1 - s/assert/early return/

Maybe we should keep the assert so we have a hope of catching this case in Debug builds?
Comment 3 Brian Weinstein 2011-10-20 12:30:30 PDT
Comment on attachment 111826 [details]
Patch v1 - s/assert/early return/

Do we still want the assert to help us catch this in the future?
Comment 4 Darin Adler 2011-10-20 12:31:39 PDT
Comment on attachment 111826 [details]
Patch v1 - s/assert/early return/

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

> Source/WebKit2/WebProcess/WebPage/WebPage.cpp:2076
> -    ASSERT(m_contextMenu);
> +    if (!m_contextMenu)
> +        return;

If we don’t know why it happens and hope to some day track it down, then we could augment the assert with a return rather than replacing it with a return.

But if we think it’s not surprising since the back and forth is cross-process without a strong guarantee the processes are in-sync, then perhaps we should land this patch as-is.

Also, if there is some kind of race her then maybe each context menu needs an ID so choosing an item from an old context menu doesn’t get mixed up with a new one.
Comment 5 Brady Eidson 2011-10-20 12:32:07 PDT
In radar Darin had mentioned to me the following:

"A principle: ...It is not safe to assert something if it’s dependent on the state of the other process."

I don't disagree with him.
Comment 6 Brady Eidson 2011-10-20 12:33:18 PDT
Sending        WebKit2/ChangeLog
Sending        WebKit2/WebProcess/WebPage/WebPage.cpp
Transmitting file data ..
Committed revision 98013.