<?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>80982</bug_id>
          
          <creation_ts>2012-03-13 05:09:12 -0700</creation_ts>
          <short_desc>[Qt] RunLoopQt is missing reentrancy guards</short_desc>
          <delta_ts>2012-05-16 07:23:01 -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>Platform</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</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>
          <dependson>81671</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Simon Hausmann">hausmann</reporter>
          <assigned_to name="Simon Hausmann">hausmann</assigned_to>
          <cc>abecsi</cc>
    
    <cc>dinu.jacob</cc>
    
    <cc>webkit.review.bot</cc>
    
    <cc>yael</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>577239</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Hausmann">hausmann</who>
    <bug_when>2012-03-13 05:09:12 -0700</bug_when>
    <thetext>This is mostly relevant to WebKit 2, where the following scenario takes place:

Setup: The web process runs two event loops, the main event loop and the event loop with the socket notifier that listens on the socket connected to the uiprocess.

    1) The web process receives an incoming message from the ui process to create a new page.

    2) The message is received in the WorkQueue&apos;s thread of the connection object. It is read from the socket and queued in the list of incoming messages. RunLoop::dispatch() is called with Connection::dispatchMessages as message to call from the main runloop&apos;s thread. This will cause the Qt implementation of RunLoop::wakeUp to post a message to the main event loop, causing it to wake up.

    2) The main event loop&apos;s thread wakes up and calls Connection::dispatchMessages() via RunLoop::performWork(). dispatchMessages() runs a while (true) loop to process all new messages from the queue of incoming messages.

    3) In the mean time on the webprocess&apos; message receiving thread, another message is received, one for a specific page - for example loadUrl for the page that was supposed to be created in the previous message. The message is read from the socket, queued in the queue of incoming messages and a message is posted to the main event loop again to wake it up.

    4) The message (create new page) is processed, a new WebCore::Page is created, among other things clients like NetworkStateNotifier are created, which initiated the Qt bearer management. Unfortunately the implementation of the latter in some environments does things like calling QEventLoop::exec() while waiting for some system component to respond, which results in the processing of pending events in the main event loop.

    5) The wake-up scheduled in step (3) is triggered through the nested event loop, causing dispatchMessages() to be called. This will take the next message (loadUrl) from the queue and start processing it, even though we are still in the process of constructing our initial page. As it happens the message is not processed successfully because the corresponding page id is not registered yet.

As a result the start-up sequence is kind of random and sometimes an initially requested url is loaded, sometimes it isn&apos;t.

The proposed fix is to prevent the Qt implementation of RunLoop to call performWork() recursively. Due to the nature of message queuing, in the above scenario the message would still be received, read and queued in the list of incoming messages. It will consequently be processed by either the while (true) loop of the first, initial dispatchMessages() call or by a subsequent one.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>577249</commentid>
    <comment_count>1</comment_count>
      <attachid>131596</attachid>
    <who name="Simon Hausmann">hausmann</who>
    <bug_when>2012-03-13 05:32:45 -0700</bug_when>
    <thetext>Created attachment 131596
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>577279</commentid>
    <comment_count>2</comment_count>
    <who name="Dinu Jacob">dinu.jacob</who>
    <bug_when>2012-03-13 07:07:45 -0700</bug_when>
    <thetext>Very well written detailed description :) This solution makes it Qt specific!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>577355</commentid>
    <comment_count>3</comment_count>
    <who name="Simon Hausmann">hausmann</who>
    <bug_when>2012-03-13 08:43:33 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; Very well written detailed description :) This solution makes it Qt specific!

Right, it&apos;s a Qt specific solution for what I think is a Qt specific problem at this point.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>578354</commentid>
    <comment_count>4</comment_count>
      <attachid>131596</attachid>
    <who name="Tor Arne Vestbø">vestbo</who>
    <bug_when>2012-03-14 06:43:51 -0700</bug_when>
    <thetext>Comment on attachment 131596
Patch

nice!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>578393</commentid>
    <comment_count>5</comment_count>
      <attachid>131596</attachid>
    <who name="Andras Becsi">abecsi</who>
    <bug_when>2012-03-14 08:02:41 -0700</bug_when>
    <thetext>Comment on attachment 131596
Patch

Clearing flags on attachment: 131596

Committed r110699: &lt;http://trac.webkit.org/changeset/110699&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>578394</commentid>
    <comment_count>6</comment_count>
    <who name="Andras Becsi">abecsi</who>
    <bug_when>2012-03-14 08:03:20 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>625401</commentid>
    <comment_count>7</comment_count>
    <who name="Simon Hausmann">hausmann</who>
    <bug_when>2012-05-16 07:23:01 -0700</bug_when>
    <thetext>Change http://trac.webkit.org/changeset/117286 rolled out this change, as it broke modal event loop handling. The symptom of this issue is fixed differently, and there&apos;s a growing trend in qt to stop doing evil local-event-loop spinning in synchronous APIs (and instead block on worker threads), so I think it&apos;s safe to go back to the previous approach for now.

Changing this to WONTFIX in the meantime.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>131596</attachid>
            <date>2012-03-13 05:32:45 -0700</date>
            <delta_ts>2012-03-14 08:02:40 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-80982-20120313133242.patch</filename>
            <type>text/plain</type>
            <size>2723</size>
            <attacher name="Simon Hausmann">hausmann</attacher>
            
              <data encoding="base64">U3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