<?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>48918</bug_id>
          
          <creation_ts>2010-11-03 09:18:33 -0700</creation_ts>
          <short_desc>Crashes in WebCore::DocumentMarkerController::removeMarkersFromMarkerMapVectorPair() when deleting multiple lines of text.</short_desc>
          <delta_ts>2010-11-03 16:55:43 -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>Mac</rep_platform>
          <op_sys>OS X 10.6</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="Jia Pu">jiapu.mail</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>adele</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>304054</commentid>
    <comment_count>0</comment_count>
    <who name="Jia Pu">jiapu.mail</who>
    <bug_when>2010-11-03 09:18:33 -0700</bug_when>
    <thetext>To reproduce:

1. type
     &quot;adfef
      adfef&quot;
2. Select all.
3. Try to delete the selection.

It crashes with following call stack:
&gt;  1 com.apple.WebCore              0x7fff877fea64 WebCore::DocumentMarkerController::removeMarkersFromMarkerMapVectorPair(WebCore::Node*, std::pair&lt;WTF::Vector&lt;WebCore::DocumentMarker, 0ul&gt;, WTF::Vector&lt;WebCore::IntRect, 0ul&gt; &gt;*, WebCore::DocumentMarker::MarkerType) + 0x2a
   2 com.apple.WebCore              0x7fff877fed64 WebCore::DocumentMarkerController::removeMarkers(WebCore::Node*, WebCore::DocumentMarker::MarkerType) + 0x48
   3 com.apple.WebCore              0x7fff8788566b WebCore::Editor::removeSpellAndCorrectionMarkersFromWordsToBeEdited(bool) + 0xe21
   4 com.apple.WebCore              0x7fff875dcdd6 WebCore::TypingCommand::deleteKeyPressed(WebCore::TextGranularity, bool) + 0x36
   5 com.apple.WebCore              0x7fff875d3b32 WebCore::EditCommand::apply() + 0x84
   6 com.apple.WebCore              0x7fff875dcd43 WebCore::TypingCommand::deleteKeyPressed(WebCore::Document*, bool, WebCore::TextGranularity, bool) + 0x167
   7 com.apple.WebCore              0x7fff875dcb78 WebCore::Editor::deleteWithDirection(WebCore::SelectionController::EDirection, WebCore::TextGranularity, bool, bool) + 0x1ec
   8 com.apple.WebCore              0x7fff8789011f WebCore::executeDeleteBackward(WebCore::Frame*, WebCore::Event*, WebCore::EditorCommandSource, WTF::String const&amp;) + 0x1f
   9 com.apple.WebCore              0x7fff8788eb66 WebCore::Editor::Command::execute(WTF::String const&amp;, WebCore::Event*) const + 0x94
  10 com.apple.WebCore              0x7fff875d9757 WebCore::Editor::Command::execute(WebCore::Event*) const + 0x1f
  11 com.apple.WebKit               0x7fff86386fdb -[WebHTMLView(WebNSTextInputSupport) doCommandBySelector:] + 0x25b
  12 com.apple.WebKit               0x7fff863869b8 -[WebHTMLView(WebInternal) _interceptEditingKeyEvent:shouldSaveCommand:] + 0x288
  13 com.apple.WebKit               0x7fff86386abe WebEditorClient::handleKeyboardEvent(WebCore::KeyboardEvent*) + 0x5c
  14 com.apple.WebCore              0x7fff8746fc34 WebCore::EventHandler::defaultKeyboardEventHandler(WebCore::KeyboardEvent*) + 0x42
  15 com.apple.WebCore              0x7fff87415f5d WebCore::Node::defaultEventHandler(WebCore::Event*) + 0x9d
  16 com.apple.WebCore              0x7fff87415b5b WebCore::Node::dispatchGenericEvent(WTF::PassRefPtr&lt;WebCore::Event&gt;) + 0x3a5
  17 com.apple.WebCore              0x7fff874156bb WebCore::Node::dispatchEvent(WTF::PassRefPtr&lt;WebCore::Event&gt;) + 0xe9
  18 com.apple.WebCore              0x7fff8746fb62 WebCore::EventTarget::dispatchEvent(WTF::PassRefPtr&lt;WebCore::Event&gt;, int&amp;) + 0x56
  19 com.apple.WebCore              0x7fff8746f247 WebCore::EventHandler::keyEvent(WebCore::PlatformKeyboardEvent const&amp;) + 0x321
  20 com.apple.WebCore              0x7fff8746ff0d WebCore::EventHandler::keyEvent(NSEvent*) + 0x35
….</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>304058</commentid>
    <comment_count>1</comment_count>
    <who name="Jia Pu">jiapu.mail</who>
    <bug_when>2010-11-03 09:21:35 -0700</bug_when>
    <thetext>&lt;rdar://problem/8620602&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>304061</commentid>
    <comment_count>2</comment_count>
    <who name="Jia Pu">jiapu.mail</who>
    <bug_when>2010-11-03 09:26:08 -0700</bug_when>
    <thetext>Seems a more reliable reproducible case is:

&quot;abc
abc

abc
abc&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>304063</commentid>
    <comment_count>3</comment_count>
    <who name="Jia Pu">jiapu.mail</who>
    <bug_when>2010-11-03 09:29:06 -0700</bug_when>
    <thetext>When use TextIterator to iterate multiple lines of text, the returned pointer by TextIterator::node() can be null. Need to guard against this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>304138</commentid>
    <comment_count>4</comment_count>
      <attachid>72844</attachid>
    <who name="Jia Pu">jiapu.mail</who>
    <bug_when>2010-11-03 11:21:55 -0700</bug_when>
    <thetext>Created attachment 72844
Proposed patch (v1)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>304229</commentid>
    <comment_count>5</comment_count>
      <attachid>72844</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2010-11-03 13:07:32 -0700</bug_when>
    <thetext>Comment on attachment 72844
Proposed patch (v1)

It’s extremely inefficient to use TextIterator’s node() function on every node in a range you are iterating. The TextIterator::range() function is far more efficient. We should probably have a comment about that in TextIterator.h and perhaps even rename node() to deprecatedNode().

This code change is OK, but I worry that removeSpellAndCorrectionMarkersFromWordsToBeEdited can be pathologically slow with a large selection because of the use of TextIterator::node().</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>304256</commentid>
    <comment_count>6</comment_count>
    <who name="Jia Pu">jiapu.mail</who>
    <bug_when>2010-11-03 13:42:51 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; (From update of attachment 72844 [details])
&gt; It’s extremely inefficient to use TextIterator’s node() function on every node in a range you are iterating. The TextIterator::range() function is far more efficient. We should probably have a comment about that in TextIterator.h and perhaps even rename node() to deprecatedNode().
&gt; 
&gt; This code change is OK, but I worry that removeSpellAndCorrectionMarkersFromWordsToBeEdited can be pathologically slow with a large selection because of the use of TextIterator::node().

Thanks for reviewing, Darin. I have create bug #48949 to track replacing Consider replacing TextIterator::node() with TextIterator::range().</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>304356</commentid>
    <comment_count>7</comment_count>
      <attachid>72844</attachid>
    <who name="Adele Peterson">adele</who>
    <bug_when>2010-11-03 16:53:18 -0700</bug_when>
    <thetext>Comment on attachment 72844
Proposed patch (v1)

I&apos;ll land this manually since the commit queue is taking forever.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>304358</commentid>
    <comment_count>8</comment_count>
    <who name="Adele Peterson">adele</who>
    <bug_when>2010-11-03 16:55:43 -0700</bug_when>
    <thetext>Committed revision 71284.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>72844</attachid>
            <date>2010-11-03 11:21:55 -0700</date>
            <delta_ts>2010-11-03 16:53:18 -0700</delta_ts>
            <desc>Proposed patch (v1)</desc>
            <filename>webkit_bug48918.patch</filename>
            <type>text/plain</type>
            <size>1847</size>
            <attacher name="Jia Pu">jiapu.mail</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFdlYkNvcmUvQ2hhbmdlTG9n
CShyZXZpc2lvbiA3MTI1MSkKKysrIFdlYkNvcmUvQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBA
IC0xLDMgKzEsMTggQEAKKzIwMTAtMTEtMDMgIEppYSBQdSAgPGpwdUBhcHBsZS5jb20+CisKKyAg
ICAgICAgUmV2aWV3ZWQgYnkgTk9CT0RZIChPT1BTISkuCisKKyAgICAgICAgQ3Jhc2hlcyBpbiBX
ZWJDb3JlOjpEb2N1bWVudE1hcmtlckNvbnRyb2xsZXI6OnJlbW92ZU1hcmtlcnNGcm9tTWFya2Vy
TWFwVmVjdG9yUGFpcigpIHdoZW4gZGVsZXRpbmcgbXVsdGlwbGUgbGluZXMgb2YgdGV4dC4KKyAg
ICAgICAgaHR0cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTQ4OTE4CisgICAg
ICAgIDxyZGFyOi8vcHJvYmxlbS84NjIwNjAyPgorCisgICAgICAgIEkgaGF2ZW4ndCBiZWVuIGFi
bGUgdG8gZm91bmQgYSByZWFsaWFibGUgd2F5IHRvIHJlcHJvZHVjZSB0aGUgYnVnLiBIb3dldmVy
LCB3aGVuZXZlciBpdCBoYXBwZW5zLAorICAgICAgICB0aGUgY3Jhc2ggaXMgY2F1c2VkIGJ5IGEg
bnVsbCBub2RlIHBvaW50ZXIgcmV0dXJuZWQgYnkgVGV4dEl0ZXJhdG9yLiBTbyBpdCBzZWVtcyB0
byBiZSBhIAorICAgICAgICBzYWZlIGZpeCB0byBndWFyZCBhZ2FpbnN0IHRoYXQuIAorCisgICAg
ICAgICogZWRpdGluZy9FZGl0b3IuY3BwOgorICAgICAgICAoV2ViQ29y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
b3JkIGNhbiBiZWxvbmcgdG8gdGhlIHNhbWUgbm9kZQogICAgICAgICAgICAgYm9vbCBwcm9jZXNz
Rmlyc3RXb3JkID0gbm9kZSA9PSBzdGFydE9mRmlyc3RXb3JkLmRlZXBFcXVpdmFsZW50KCkuY29u
dGFpbmVyTm9kZSgpICYmIGRvY3VtZW50LT5tYXJrZXJzKCktPmhhc01hcmtlcnMocmFuZ2VPZkZp
cnN0V29yZC5nZXQoKSwgRG9jdW1lbnRNYXJrZXI6OlNwZWxsaW5nIHwgRG9jdW1lbnRNYXJrZXI6
OkNvcnJlY3Rpb25JbmRpY2F0b3IpOwo=
</data>
<flag name="review"
          id="63172"
          type_id="1"
          status="+"
          setter="darin"
    />
    <flag name="commit-queue"
          id="63173"
          type_id="3"
          status="-"
          setter="adele"
    />
          </attachment>
      

    </bug>

</bugzilla>