<?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>62592</bug_id>
          
          <creation_ts>2011-06-13 13:19:40 -0700</creation_ts>
          <short_desc>[Chromium] WebNotification should check if ScriptExecutionContext is gone before dispatching events</short_desc>
          <delta_ts>2011-06-13 17:39:06 -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>WebCore Misc.</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></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jian Li">jianli</reporter>
          <assigned_to name="Jian Li">jianli</assigned_to>
          <cc>dimich</cc>
    
    <cc>eric</cc>
    
    <cc>fishd</cc>
    
    <cc>levin</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>419802</commentid>
    <comment_count>0</comment_count>
    <who name="Jian Li">jianli</who>
    <bug_when>2011-06-13 13:19:40 -0700</bug_when>
    <thetext>WebNotification should check if ScriptExecutionContext is gone before dispatching events. Otherwise, we will see crashes like the following:

0x0241d382	 [chrome.dll	 - v8abstracteventlistener.cpp:76]	WebCore::V8AbstractEventListener::handleEvent(WebCore::ScriptExecutionContext *,WebCore::Event *)
0x0232cc87	 [chrome.dll	 - eventtarget.cpp:389]	WebCore::EventTarget::fireEventListeners(WebCore::Event *,WebCore::EventTargetData *,WTF::Vector&lt;WebCore::RegisteredEventListener,1&gt; &amp;)
0x0232cbbe	 [chrome.dll	 - eventtarget.cpp:358]	WebCore::EventTarget::fireEventListeners(WebCore::Event *)
0x0232cb5a	 [chrome.dll	 - eventtarget.cpp:340]	WebCore::EventTarget::dispatchEvent(WTF::PassRefPtr&lt;WebCore::Event&gt;)
0x025e21cb	 [chrome.dll	 - webnotification.cpp:134]	WebKit::WebNotification::dispatchCloseEvent(bool)
0x01cb16c9	 [chrome.dll	 - notification_provider.cc:154]	NotificationProvider::OnClose(int,bool)
0x01cb1103	 [chrome.dll	 - notification_provider.cc:88]	NotificationProvider::OnMessageReceived(IPC::Message const &amp;)
0x01ca1cda	 [chrome.dll	 - render_view.cc:592]	RenderView::OnMessageReceived(IPC::Message const &amp;)
0x01c8a77f	 [chrome.dll	 - message_router.cc:46]	MessageRouter::RouteMessage(IPC::Message const &amp;)
0x01c8a759	 [chrome.dll	 - message_router.cc:38]	MessageRouter::OnMessageReceived(IPC::Message const &amp;)
0x01c8455e	 [chrome.dll	 - child_thread.cc:175]	ChildThread::OnMessageReceived(IPC::Message const &amp;)
0x01edd3f2	 [chrome.dll	 - task.h:338]	RunnableMethod&lt;ProfileWriter,void ( ProfileWriter::*)(GURL const &amp;),Tuple1&lt;GURL&gt; &gt;::Run()
0x01c451a4	 [chrome.dll	 - message_loop.cc:102]	`anonymous namespace&apos;::TaskClosureAdapter::Run()
0x01c45c98	 [chrome.dll	 - message_loop.cc:482]	MessageLoop::RunTask(MessageLoop::PendingTask const &amp;)
0x01c45d1b	 [chrome.dll	 - message_loop.cc:500]	MessageLoop::DeferOrRunPendingTask(MessageLoop::PendingTask const &amp;)
0x01c46096	 [chrome.dll	 - message_loop.cc:691]	MessageLoop::DoWork()
0x01c5094f	 [chrome.dll	 - message_pump_default.cc:50]	base::MessagePumpDefault::Run(base::MessagePump::Delegate *)
0x01c45bb1	 [chrome.dll	 - message_loop.cc:449]	MessageLoop::RunInternal()
0x01c45b36	 [chrome.dll	 - message_loop.cc:422]	MessageLoop::RunHandler()
0x01c45a2a	 [chrome.dll	 - message_loop.cc:346]	MessageLoop::Run()
0x01c9e3fd	 [chrome.dll	 - renderer_main.cc:235]	RendererMain(MainFunctionParams const &amp;)
0x01c348ef	 [chrome.dll	 - chrome_main.cc:815]	ChromeMain
0x004022b8	 [chrome.exe	 - client_util.cc:254]	MainDllLoader::Launch(HINSTANCE__ *,sandbox::SandboxInterfaceInfo *)
0x0040595a	 [chrome.exe	 - chrome_exe_main_win.cc:46]	wWinMain
0x00454f9f	 [chrome.exe	 - crt0.c:263]	__tmainCRTStartup
0x7c817076	 [kernel32.dll	 + 0x00017076]	BaseProcessStart

This is a regression from http://trac.webkit.org/changeset/83900. It helps to expose the underlying problem in WebNotification code.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>419840</commentid>
    <comment_count>1</comment_count>
      <attachid>97005</attachid>
    <who name="Jian Li">jianli</who>
    <bug_when>2011-06-13 13:57:02 -0700</bug_when>
    <thetext>Created attachment 97005
Proposed Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>419853</commentid>
    <comment_count>2</comment_count>
      <attachid>97005</attachid>
    <who name="David Levin">levin</who>
    <bug_when>2011-06-13 14:07:04 -0700</bug_when>
    <thetext>Comment on attachment 97005
Proposed Patch

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

&gt; Source/WebKit/chromium/src/WebNotification.cpp:144
&gt; +    if (!m_private-&gt;scriptExecutionContext())

1. How does this get cleared?
2. How did http://trac.webkit.org/changeset/83900 expose this issue?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>419874</commentid>
    <comment_count>3</comment_count>
      <attachid>97005</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2011-06-13 14:32:35 -0700</bug_when>
    <thetext>Comment on attachment 97005
Proposed Patch

How do we test this?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>419893</commentid>
    <comment_count>4</comment_count>
    <who name="Darin Fisher (:fishd, Google)">fishd</who>
    <bug_when>2011-06-13 14:51:14 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; (From update of attachment 97005 [details])
&gt; How do we test this?

This can be tested via webkit_unit_tests.  Just add a gtest in chromium/tests/.  You probably need something like WebFrameTest from WebFrameTests.cpp so that you can setup a real document.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>420070</commentid>
    <comment_count>5</comment_count>
    <who name="Jian Li">jianli</who>
    <bug_when>2011-06-13 17:06:16 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; (In reply to comment #3)
&gt; &gt; (From update of attachment 97005 [details] [details])
&gt; &gt; How do we test this?
&gt; 
&gt; This can be tested via webkit_unit_tests.  Just add a gtest in chromium/tests/.  You probably need something like WebFrameTest from WebFrameTests.cpp so that you can setup a real document.

The crash seems to be caused by the timing between closing main page and closing notification balloon. If it happens that the code is executed in the following order:
  NotificationCenter::disconnectFrame
  Notification::contextDestroyed
  NotificationProvider::OnClose
  NotificationProvider::~NotificationProvider
we will hit the crash. NotificationCenter::disconnectFrame calls m_notificationPresenter-&gt;cancelRequestsForPermission (just dummy stub) and sets m_notificationPresenter to 0. Then when Notification::contextDestroyed is called, we cannot delegate to presenter()-&gt;notificationObjectDestroyed since presenter() is NULL. After that, when NotificationProvider::OnClose is called for the balloon close, we still have valid WebNotification in the list and will call from WebNotification into WebCore::Notification to dispatch the event, but Notification::m_scriptExecutionContext is gone.

I think the good fix is to implement cancelRequestsForPermission and delegate into NotificationProvider to clear the list. However, this change involves 2-side change and will take some time to develop and checkin. So probably we should land this quick fix so that it can be merged into release branches.

I am not able to repro the crash since it only happens with certain timing. Sorry for not able to provide a consistent test for it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>420071</commentid>
    <comment_count>6</comment_count>
      <attachid>97005</attachid>
    <who name="Jian Li">jianli</who>
    <bug_when>2011-06-13 17:06:43 -0700</bug_when>
    <thetext>Comment on attachment 97005
Proposed Patch

Can you review again?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>420101</commentid>
    <comment_count>7</comment_count>
    <who name="Jian Li">jianli</who>
    <bug_when>2011-06-13 17:39:06 -0700</bug_when>
    <thetext>Committed as https://trac.webkit.org/changeset/88738.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>97005</attachid>
            <date>2011-06-13 13:57:02 -0700</date>
            <delta_ts>2011-06-13 17:11:45 -0700</delta_ts>
            <desc>Proposed Patch</desc>
            <filename>62592</filename>
            <type>text/plain</type>
            <size>3399</size>
            <attacher name="Jian Li">jianli</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJLaXQvY2hyb21pdW0vQ2hhbmdlTG9nIGIvU291cmNlL1dl
YktpdC9jaHJvbWl1bS9DaGFuZ2VMb2cKaW5kZXggOWY5ZWFjNC4uNGM4Y2JhYSAxMDA3NTUKLS0t
IGEvU291cmNlL1dlYktpdC9jaHJvbWl1bS9DaGFuZ2VMb2cKKysrIGIvU291cmNlL1dlYktpdC9j
aHJvbWl1bS9DaGFuZ2VMb2cKQEAgLTEsMyArMSwyMCBAQAorMjAxMS0wNi0xMyAgSmlhbiBMaSAg
PGppYW5saUBjaHJvbWl1bS5vcmc+CisKKyAgICAgICAgUmV2aWV3ZWQgYnkgTk9CT0RZIChPT1BT
ISkuCisKKyAgICAgICAgW0Nocm9taXVtXSBXZWJOb3RpZmljYXRpb24gc2hvdWxkIGNoZWNrIGlm
IFNjcmlwdEV4ZWN1dGlvbkNvbnRleHQgaXMgZ29uZQorICAgICAgICBiZWZvcmUgZGlzcGF0Y2hp
bmcgZXZlbnRzLgorICAgICAgICBodHRwczovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/
aWQ9NjI1OTIKKworICAgICAgICAqIHB1YmxpYy9XZWJOb3RpZmljYXRpb24uaDoKKyAgICAgICAg
KiBzcmMvV2ViTm90aWZpY2F0aW9uLmNwc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2F0b3IgZ2VzdHVyZUluZGljYXRvcihEZWZpbml0ZWx5UHJvY2Vzc2luZ1VzZXJHZXN0
dXJlKTsKLSAgICBSZWZQdHI8RXZlbnQ+IGV2ZW50ID0gRXZlbnQ6OmNyZWF0ZShldmVudE5hbWVz
KCkuY2xpY2tFdmVudCwgZmFsc2UsIHRydWUpOworICAgIGRpc3BhdGNoRXZlbnQoZXZlbnROYW1l
cygpLmNsaWNrRXZlbnQpOworfQorCit2b2lkIFdlYk5vdGlmaWNhdGlvbjo6ZGlzcGF0Y2hFdmVu
dChjb25zdCBXVEY6OkF0b21pY1N0cmluZyYgdHlwZSkKK3sKKyAgICAvLyBEbyBub3QgZGlzcGF0
Y2ggaWYgdGhlIGNvbnRleHQgaXMgZ29uZS4KKyAgICBpZiAoIW1fcHJpdmF0ZS0+c2NyaXB0RXhl
Y3V0aW9uQ29udGV4dCgpKQorICAgICAgICByZXR1cm47CisKKyAgICBSZWZQdHI8RXZlbnQ+IGV2
ZW50ID0gRXZlbnQ6OmNyZWF0ZSh0eXBlLCBmYWxzZSwgdHJ1ZSk7CiAgICAgbV9wcml2YXRlLT5k
aXNwYXRjaEV2ZW50KGV2ZW50LnJlbGVhc2UoKSk7CiB9CiAK
</data>
<flag name="review"
          id="90816"
          type_id="1"
          status="+"
          setter="levin"
    />
    <flag name="commit-queue"
          id="90817"
          type_id="3"
          status="-"
          setter="jianli"
    />
          </attachment>
      

    </bug>

</bugzilla>