<?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>25312</bug_id>
          
          <creation_ts>2009-04-21 13:41:47 -0700</creation_ts>
          <short_desc>REGRESSION: Infinite loop in WebCore::Position::upstream while selecting a block of text</short_desc>
          <delta_ts>2009-04-23 15:47:31 -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>New Bugs</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar, NeedsReduction</keywords>
          <priority>P1</priority>
          <bug_severity>Critical</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Finnur Thorarinsson">finnur.webkit</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>adele</cc>
    
    <cc>darin</cc>
    
    <cc>ddkilzer</cc>
    
    <cc>eric</cc>
    
    <cc>justin.garcia</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>118310</commentid>
    <comment_count>0</comment_count>
    <who name="Finnur Thorarinsson">finnur.webkit</who>
    <bug_when>2009-04-21 13:41:47 -0700</bug_when>
    <thetext>Please disregard the version above. I filed this against Chromium, which is where this reproduces - but eseidel asked that I file this here so we can CC members of WebKit on this bug. This was originally filed as http://code.google.com/p/chromium/issues/detail?id=10805.

Repro:

In the dev build of Google Chrome, I selected a block of text on Facebook and noticed that the renderer became unresponsive, spinning the CPU at 100%. I reproduced this over and over with no problem (across restart of Chrome and across an update to the latest dev build, as it was reproducing on the previous one as well). 

I took a process snapshot once (see attachment on Chromium bug) and was able to step through with WinDbg. I noticed that once I try to Step Out of WebCore::Position::upstream it starts spinning the CPU. 

ChildEBP RetAddr  
00caf844 01f1ab81 chrome_1c30000!WebCore::canHaveChildrenForEditing+0xc2
00caf84c 01f1ab6e chrome_1c30000!WebCore::editingIgnoresContent+0x8
00caf850 01ebf97d chrome_1c30000!WebCore::isAtomicNode+0x16
00caf858 01ebfa34 chrome_1c30000!WebCore::isStreamer+0x10
00caf8a4 01ea01d9 chrome_1c30000!WebCore::Position::upstream+0xaa
00caf8e0 01e9f23b chrome_1c30000!WebCore::VisiblePosition::canonicalPosition+0x35
00caf910 01e9f200 chrome_1c30000!WebCore::VisiblePosition::init+0x26
00caf928 01ea93a0 chrome_1c30000!WebCore::VisiblePosition::VisiblePosition+0x2e
00caf944 01f3054c chrome_1c30000!WebCore::RenderObject::createVisiblePosition+0xa1
00caf968 01ea8933 chrome_1c30000!WebCore::RenderText::positionForPoint+0x173
00caf980 01f29f25 chrome_1c30000!WebCore::RenderObject::positionForCoordinates+0x1d
00caf99c 01f29fef chrome_1c30000!WebCore::positionForPointWithInlineChildren+0x7f
00caf9cc 01ea8933 chrome_1c30000!WebCore::RenderBlock::positionForPoint+0xb2
00caf9e4 01f29e9f chrome_1c30000!WebCore::RenderObject::positionForCoordinates+0x1d
00cafa0c 01f2a041 chrome_1c30000!WebCore::positionForPointRespectingEditingBoundaries+0xaf
00cafa34 01ea8933 chrome_1c30000!WebCore::RenderBlock::positionForPoint+0x104
00cafa4c 01f29e9f chrome_1c30000!WebCore::RenderObject::positionForCoordinates+0x1d
00cafa74 01f2a041 chrome_1c30000!WebCore::positionForPointRespectingEditingBoundaries+0xaf
00cafa98 01eb9bf3 chrome_1c30000!WebCore::RenderBlock::positionForPoint+0x104
00cafb20 01eb9b23 chrome_1c30000!WebCore::EventHandler::updateSelectionForMouseDrag+0x49

Basically, it is looping forever in Position::upstream because it seems to never go into any of the if 
statements within the for loop. It just loops forever.

I stepped into PositionIterator::decrement(). m_parent points to a node, but m_child is 
NULL. As a result, decrement() just calls Position::uncheckedPreviousOffset(), which 
effectively decrements m_offset... 

However, m_offset is this ridiculously large number (2061442196 and shrinking)... Does 
that make any sense?

NOTE: I am not able to repro this on my development machine and not able to repro this in Safari 4 on my laptop either. There is something about my Thinkpad laptop that triggers this, it seems.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118311</commentid>
    <comment_count>1</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2009-04-21 14:08:50 -0700</bug_when>
    <thetext>I think it&apos;s more likely that somehow the copy of chromium on your thinkpad has a different copy of WebKit.  It&apos;s possible that this regressed briefly and has been since fixed?

I&apos;ve CC&apos;d the other two who&apos;ve worked in this function recently.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118312</commentid>
    <comment_count>2</comment_count>
    <who name="Justin Garcia">justin.garcia</who>
    <bug_when>2009-04-21 14:11:23 -0700</bug_when>
    <thetext>I think ddkilzer ran into this, let me look...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118406</commentid>
    <comment_count>3</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2009-04-22 12:46:23 -0700</bug_when>
    <thetext>&lt;rdar://problem/6805717&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118529</commentid>
    <comment_count>4</comment_count>
    <who name="Justin Garcia">justin.garcia</who>
    <bug_when>2009-04-23 13:51:01 -0700</bug_when>
    <thetext>I don&apos;t know that Position checks it&apos;s offset to see if it&apos;s valid.  Perhaps this could be the problem (from RenderObject::createVisiblePosition):

        // Find non-anonymous content before.
        renderer = child;
        while ((renderer = renderer-&gt;previousInPreOrder())) {
            if (renderer == parent)
                break;
            if (Node* node = renderer-&gt;node())
                return VisiblePosition(node, numeric_limits&lt;int&gt;::max(), DOWNSTREAM);
        }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118530</commentid>
    <comment_count>5</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2009-04-23 13:56:34 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; I don&apos;t know that Position checks it&apos;s offset to see if it&apos;s valid.  Perhaps
&gt; this could be the problem (from RenderObject::createVisiblePosition):
&gt; 
&gt;         // Find non-anonymous content before.
&gt;         renderer = child;
&gt;         while ((renderer = renderer-&gt;previousInPreOrder())) {
&gt;             if (renderer == parent)
&gt;                 break;
&gt;             if (Node* node = renderer-&gt;node())
&gt;                 return VisiblePosition(node, numeric_limits&lt;int&gt;::max(),
&gt; DOWNSTREAM);
&gt;         }
&gt; 

Position doesn&apos;t check the offset, but I think VisiblePosition should.

If it doesn’t, then my bad; I wrote the code above and maybe that did cause the bug!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118531</commentid>
    <comment_count>6</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2009-04-23 13:57:46 -0700</bug_when>
    <thetext>&lt;rdar://problem/6788905&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118532</commentid>
    <comment_count>7</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2009-04-23 13:59:09 -0700</bug_when>
    <thetext>I probably broke this in http://trac.webkit.org/changeset/41928</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118533</commentid>
    <comment_count>8</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2009-04-23 14:01:36 -0700</bug_when>
    <thetext>The fix is probably to use lastEditingOffsetForNode instead of numeric_limits&lt;int&gt;::max() in createVisiblePosition. I’d just jump in and do the fix myself, but we also need a regression tests.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118535</commentid>
    <comment_count>9</comment_count>
    <who name="Justin Garcia">justin.garcia</who>
    <bug_when>2009-04-23 14:10:05 -0700</bug_when>
    <thetext>&gt; Position doesn&apos;t check the offset

Ya, and I don&apos;t think we should here because I believe we allow invalid positions for ending selections that won&apos;t be valid until Undo.

&gt; but I think VisiblePosition should.

maybe.  although validation here would require an extra call to nodeIndex/childnodecount in some situations.  probably just fix it at the call site.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118543</commentid>
    <comment_count>10</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2009-04-23 14:17:56 -0700</bug_when>
    <thetext>Actually VisiblePosition *is* checking the offset; just very slowly. That’s where we’re hanging!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118544</commentid>
    <comment_count>11</comment_count>
    <who name="Justin Garcia">justin.garcia</who>
    <bug_when>2009-04-23 14:20:34 -0700</bug_when>
    <thetext>&gt; Actually VisiblePosition *is* checking the offset; just very slowly. That’s
&gt; where we’re hanging!

by &apos;check&apos; i just meant verify that the offset is no greater than lastEditingOffsetForNode...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118553</commentid>
    <comment_count>12</comment_count>
      <attachid>29717</attachid>
    <who name="Adele Peterson">adele</who>
    <bug_when>2009-04-23 15:42:43 -0700</bug_when>
    <thetext>Created attachment 29717
patch

I haven&apos;t been able to reproduce this, but I think there&apos;s value on getting this change in anyway to confirm it fixes the problem.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118554</commentid>
    <comment_count>13</comment_count>
    <who name="Adele Peterson">adele</who>
    <bug_when>2009-04-23 15:47:31 -0700</bug_when>
    <thetext>Committed revision 42794.

Please let me know if anyone can still reproduce this after this revision.  Thanks!</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>29717</attachid>
            <date>2009-04-23 15:42:43 -0700</date>
            <delta_ts>2009-04-23 15:43:09 -0700</delta_ts>
            <desc>patch</desc>
            <filename>patch_4-23-09.txt</filename>
            <type>text/plain</type>
            <size>1391</size>
            <attacher name="Adele Peterson">adele</attacher>
            
              <data encoding="base64">SW5kZXg6IENoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09P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T09PT09PT09PQotLS0gcmVuZGVyaW5nL1JlbmRlck9iamVjdC5jcHAJKHJldmlzaW9u
IDQyNzkwKQorKysgcmVuZGVyaW5nL1JlbmRlck9iamVjdC5jcHAJKHdvcmtpbmcgY29weSkKQEAg
LTIzMjgsNyArMjMyOCw3IEBAIFZpc2libGVQb3NpdGlvbiBSZW5kZXJPYmplY3Q6OmNyZWF0ZVZp
c2kKICAgICAgICAgICAgIGlmIChyZW5kZXJlciA9PSBwYXJlbnQpCiAgICAgICAgICAgICAgICAg
YnJlYWs7CiAgICAgICAgICAgICBpZiAoTm9kZSogbm9kZSA9IHJlbmRlcmVyLT5ub2RlKCkpCi0g
ICAgICAgICAgICAgICAgcmV0dXJuIFZpc2libGVQb3NpdGlvbihub2RlLCBudW1lcmljX2xpbWl0
czxpbnQ+OjptYXgoKSwgRE9XTlNUUkVBTSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIFZpc2li
bGVQb3NpdGlvbihsYXN0RGVlcEVkaXRpbmdQb3NpdGlvbkZvck5vZGUobm9kZSksIERPV05TVFJF
QU0pOwogICAgICAgICB9CiAKICAgICAgICAgLy8gVXNlIHRoZSBwYXJlbnQgaXRzZWxmIHVubGVz
cyBpdCB0b28gaXMgYW5vbnltb3VzLgo=
</data>
<flag name="review"
          id="14858"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>