<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>70535</bug_id>
          
          <creation_ts>2011-10-20 12:19:54 -0700</creation_ts>
          <short_desc>WK2 - Crash deref&apos;ing a null context menu</short_desc>
          <delta_ts>2011-10-20 12:33:18 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKit2</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Brady Eidson">beidson</reporter>
          <assigned_to name="Brady Eidson">beidson</assigned_to>
          <cc>aroben</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>487770</commentid>
    <comment_count>0</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2011-10-20 12:19:54 -0700</bug_when>
    <thetext>WK2 - Crash deref&apos;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 &lt;rdar://problem/9412849&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>487777</commentid>
    <comment_count>1</comment_count>
      <attachid>111826</attachid>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2011-10-20 12:26:50 -0700</bug_when>
    <thetext>Created attachment 111826
Patch v1 - s/assert/early return/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>487781</commentid>
    <comment_count>2</comment_count>
      <attachid>111826</attachid>
    <who name="Adam Roben (:aroben)">aroben</who>
    <bug_when>2011-10-20 12:30:11 -0700</bug_when>
    <thetext>Comment on attachment 111826
Patch v1 - s/assert/early return/

Maybe we should keep the assert so we have a hope of catching this case in Debug builds?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>487782</commentid>
    <comment_count>3</comment_count>
      <attachid>111826</attachid>
    <who name="Brian Weinstein">bweinstein</who>
    <bug_when>2011-10-20 12:30:30 -0700</bug_when>
    <thetext>Comment on attachment 111826
Patch v1 - s/assert/early return/

Do we still want the assert to help us catch this in the future?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>487784</commentid>
    <comment_count>4</comment_count>
      <attachid>111826</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2011-10-20 12:31:39 -0700</bug_when>
    <thetext>Comment on attachment 111826
Patch v1 - s/assert/early return/

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

&gt; Source/WebKit2/WebProcess/WebPage/WebPage.cpp:2076
&gt; -    ASSERT(m_contextMenu);
&gt; +    if (!m_contextMenu)
&gt; +        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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>487785</commentid>
    <comment_count>5</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2011-10-20 12:32:07 -0700</bug_when>
    <thetext>In radar Darin had mentioned to me the following:

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

I don&apos;t disagree with him.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>487787</commentid>
    <comment_count>6</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2011-10-20 12:33:18 -0700</bug_when>
    <thetext>Sending        WebKit2/ChangeLog
Sending        WebKit2/WebProcess/WebPage/WebPage.cpp
Transmitting file data ..
Committed revision 98013.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>111826</attachid>
            <date>2011-10-20 12:26:50 -0700</date>
            <delta_ts>2011-10-20 12:31:39 -0700</delta_ts>
            <desc>Patch v1 - s/assert/early return/</desc>
            <filename>patch.txt</filename>
            <type>text/plain</type>
            <size>1519</size>
            <attacher name="Brady Eidson">beidson</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJLaXQyL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBTb3VyY2UvV2Vi
S2l0Mi9DaGFuZ2VMb2cJKHJldmlzaW9uIDk4MDEwKQorKysgU291cmNlL1dlYktpdDIvQ2hhbmdl
TG9nCSh3b3JraW5nIGNvcHkpCkBAIC0xLDMgKzEsMTYgQEAKKzIwMTEtMTAtMjAgIEJyYWR5IEVp
ZHNvbiAgPGJlaWRzb25AYXBwbGUuY29tPgorCisgICAgICAgIDxyZGFyOi8vcHJvYmxlbS85NDEy
ODQ5PiBhbmQgaHR0cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTcwNTM1Cisg
ICAgICAgIFdLMiAtIENyYXNoIGRlcmVmJ2luZyBhIG51bGwgY29udGV4dCBtZW51CisKKyAgICAg
ICAgUmV2aWV3ZWQgYnkgTk9CT0RZIChPT1BTISkuCisKKyAgICAgICAgKiBXZWJQcm9jZXNzL1dl
YlBhZ2UvV2ViUGFnZS5jcHA6CisgICAgICAgIChXZWJLaXQ6OldlYlBhZ2U6OmRpZFN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6OmRpZFNl
bGVjdEl0ZW1Gcm9tQWN0aXZlQ29udGV4dE1lbnUoY29uc3QgV2ViQ29udGV4dE1lbnVJdGVtRGF0
YSYgaXRlbSkKIHsKLSAgICBBU1NFUlQobV9jb250ZXh0TWVudSk7CisgICAgaWYgKCFtX2NvbnRl
eHRNZW51KQorICAgICAgICByZXR1cm47CisKICAgICBtX2NvbnRleHRNZW51LT5pdGVtU2VsZWN0
ZWQoaXRlbSk7CiAgICAgbV9jb250ZXh0TWVudSA9IDA7CiB9Cg==
</data>
<flag name="review"
          id="109745"
          type_id="1"
          status="+"
          setter="darin"
    />
    <flag name="commit-queue"
          id="109746"
          type_id="3"
          status="-"
          setter="beidson"
    />
          </attachment>
      

    </bug>

</bugzilla>