<?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>26449</bug_id>
          
          <creation_ts>2009-06-16 10:53:08 -0700</creation_ts>
          <short_desc>UMR in WebCore::BitStack</short_desc>
          <delta_ts>2009-06-16 14:53:26 -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>PC</rep_platform>
          <op_sys>OS X 10.5</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="Tony Chang">tony</reporter>
          <assigned_to name="Tony Chang">tony</assigned_to>
          <cc>darin</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>126227</commentid>
    <comment_count>0</comment_count>
    <who name="Tony Chang">tony</who>
    <bug_when>2009-06-16 10:53:08 -0700</bug_when>
    <thetext>WebCore::BitStack was added to TextIterator in r44674.  Purify is reporting a UMR:
Uninitialized memory read in WebCore::BitStack::push(bool)
Error Location
  third_party/webkit/webcore/editing/textiterator.cpp
WebCore::BitStack::push(bool)
  third_party/webkit/webcore/editing/textiterator.cpp
WebCore::pushFullyClippedState
  third_party/webkit/webcore/editing/textiterator.cpp
WebCore::setUpFullyClippedStack
  third_party/webkit/webcore/editing/textiterator.cpp
WebCore::TextIterator::TextIterator(Range::WebCore const*,bool,bool)
  third_party/webkit/webcore/editing/textiterator.cpp
WebCore::plainTextToMallocAllocatedBuffer(class WebCore::Range const
*,unsigned int &amp;,bool)
  third_party/webkit/webcore/editing/textiterator.cpp
WebCore::plainText(Range::WebCore const*)
  third_party/webkit/webcore/dom/element.cpp
WebCore::Element::innerText(void)const
  webkit/glue/webkit_glue.cc  webkit_glue::DumpDocumentText(class WebFrame
*)
  webkit/tools/test_shell/test_shell.cc  TestShell::GetDocumentText(void)
  webkit/glue/bookmarklet_unittest.cc
BookmarkletTest_DocumentWrite_Test::TestBody(void)
  testing/gtest/src/gtest.cc  testing::Test::Run(void)
  ^^^

--

It looks like when we grow |m_words|, we don&apos;t initialize the new memory which we then use as |word| causing a UMR.  I guess we just need to assign 0 to the new memory.

Patch coming soon, but feel free to check in before me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126231</commentid>
    <comment_count>1</comment_count>
      <attachid>31354</attachid>
    <who name="Tony Chang">tony</who>
    <bug_when>2009-06-16 10:58:32 -0700</bug_when>
    <thetext>Created attachment 31354
v1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126233</commentid>
    <comment_count>2</comment_count>
      <attachid>31354</attachid>
    <who name="Darin Fisher (:fishd, Google)">fishd</who>
    <bug_when>2009-06-16 11:08:51 -0700</bug_when>
    <thetext>Comment on attachment 31354
v1

&gt; Index: WebCore/ChangeLog
...
&gt; +2009-06-16  tony chang  &lt;tony@chromium.org&gt;

nit: people normally use mixed case for their names.


&gt; +        Reviewed by NOBODY (OOPS!).
&gt; +
&gt; +        WARNING: NO TEST CASES ADDED OR CHANGED
&gt; +        
&gt; +        Fix a UMR in WebCore::BitStack by initializing new memory to 0.
&gt; +        https://bugs.webkit.org/show_bug.cgi?id=26449
&gt; +        No new tests, covered by purify.
&gt; +

nit: please be sure to add a bug link in the ChangeLog before committing.


Otherwise, R=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126237</commentid>
    <comment_count>3</comment_count>
      <attachid>31355</attachid>
    <who name="Tony Chang">tony</who>
    <bug_when>2009-06-16 11:15:32 -0700</bug_when>
    <thetext>Created attachment 31355
v2

Updated to use capitals in my name.  The changelog had the bug link already :).

Also, I don&apos;t have the commit bit, can you land this for me?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126264</commentid>
    <comment_count>4</comment_count>
      <attachid>31355</attachid>
    <who name="Darin Fisher (:fishd, Google)">fishd</who>
    <bug_when>2009-06-16 12:50:11 -0700</bug_when>
    <thetext>Comment on attachment 31355
v2

&gt; Index: WebCore/ChangeLog
...
&gt; +2009-06-16  Tony Chang  &lt;tony@chromium.org&gt;
&gt; +
&gt; +        Reviewed by NOBODY (OOPS!).
&gt; +
&gt; +        WARNING: NO TEST CASES ADDED OR CHANGED
&gt; +        
&gt; +        Fix a UMR in WebCore::BitStack by initializing new memory to 0.
&gt; +        https://bugs.webkit.org/show_bug.cgi?id=26449
&gt; +        No new tests, covered by purify.
&gt; +

Oh, sorry... I&apos;m used to see the bug reference adjacent to the text
describing the change.

You&apos;ll want to kill the WARNING line too before committing.

Still R=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126275</commentid>
    <comment_count>5</comment_count>
    <who name="Dimitri Glazkov (Google)">dglazkov</who>
    <bug_when>2009-06-16 13:32:13 -0700</bug_when>
    <thetext>Landed as http://trac.webkit.org/changeset/44735.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126298</commentid>
    <comment_count>6</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2009-06-16 14:40:32 -0700</bug_when>
    <thetext>This is a false positive in Purify. The new words don&apos;t need to be initialized! I set each bit as I use it and don&apos;t rely on the old state. But I have no objection to making the code change to make Purify happy.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126305</commentid>
    <comment_count>7</comment_count>
    <who name="Tony Chang">tony</who>
    <bug_when>2009-06-16 14:46:06 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; This is a false positive in Purify. The new words don&apos;t need to be initialized!
&gt; I set each bit as I use it and don&apos;t rely on the old state. But I have no
&gt; objection to making the code change to make Purify happy.

Are you sure about that?

01 void BitStack::push(bool bit)
02 {
03     unsigned index = m_size / bitsInWord;
04     unsigned shift = m_size &amp; bitInWordMask;
05     if (!shift &amp;&amp; index == m_words.size())  
06         m_words.grow(index + 1);
07     unsigned&amp; word = m_words[index];
08     unsigned mask = 1U &lt;&lt; shift;
09     if (bit)
10         word |= mask;
11     else
12         word &amp;= ~mask;
13     ++m_size;
14 }

In line 6 we grow the vector and don&apos;t give it a value.  In line 7, we store the value in |word|.  In line 10 or 12, we |= or &amp;= which uses the uninitialized value.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126308</commentid>
    <comment_count>8</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2009-06-16 14:48:07 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt; Are you sure about that?

I am.

&gt; 01 void BitStack::push(bool bit)
&gt; 02 {
&gt; 03     unsigned index = m_size / bitsInWord;
&gt; 04     unsigned shift = m_size &amp; bitInWordMask;
&gt; 05     if (!shift &amp;&amp; index == m_words.size())  
&gt; 06         m_words.grow(index + 1);
&gt; 07     unsigned&amp; word = m_words[index];
&gt; 08     unsigned mask = 1U &lt;&lt; shift;
&gt; 09     if (bit)
&gt; 10         word |= mask;
&gt; 11     else
&gt; 12         word &amp;= ~mask;
&gt; 13     ++m_size;
&gt; 14 }
&gt; 
&gt; In line 6 we grow the vector and don&apos;t give it a value.  In line 7, we store
&gt; the value in |word|.  In line 10 or 12, we |= or &amp;= which uses the
&gt; uninitialized value.

I think it really depends on what you mean by &quot;use&quot; the value. The |= and &amp;= set or clear the low bit, and that&apos;s the only bit that&apos;s used until we push more bits on the stack. The other bits can have any value.

But there&apos;s really no point debating this. I&apos;m fine with the code change.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126312</commentid>
    <comment_count>9</comment_count>
    <who name="Tony Chang">tony</who>
    <bug_when>2009-06-16 14:53:26 -0700</bug_when>
    <thetext>(In reply to comment #8)
&gt; I think it really depends on what you mean by &quot;use&quot; the value. The |= and &amp;=
&gt; set or clear the low bit, and that&apos;s the only bit that&apos;s used until we push
&gt; more bits on the stack. The other bits can have any value.

Ah, now I understand.  Yes, you are correct.
</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>31354</attachid>
            <date>2009-06-16 10:58:32 -0700</date>
            <delta_ts>2009-06-16 11:15:32 -0700</delta_ts>
            <desc>v1</desc>
            <filename>umr-26449.diff</filename>
            <type>text/plain</type>
            <size>1266</size>
            <attacher name="Tony Chang">tony</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFdlYkNvcmUvQ2hhbmdlTG9n
CShyZXZpc2lvbiA0NDcyNCkKKysrIFdlYkNvcmUvQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBA
IC0xLDMgKzEsMTYgQEAKKzIwMDktMDYtMTYgIHRvbnkgY2hhbmcgIDx0b255QGNocm9taXVtLm9y
Zz4KKworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMhKS4KKworICAgICAgICBXQVJO
SU5HOiBOTyBURVNUIENBU0VTIEFEREVEIE9SIENIQU5HRUQKKyAgICAgICAgCisgICAgICAgIEZp
eCBhIFVNUiBpbiBXZWJDb3JlOjpCaXRTdGFjayBieSBpbml0aWFsaXppbmcgbmV3IG1lbW9yeSB0
byAwLgorICAgICAgICBodHRwczovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/aWQ9MjY0
NDkKKyAgICAgICAgTm8gbmV3IHRlc3RzLCBjb3ZlcmVkIGJ5IHB1cmlmeS4KKworICAgICAgICAq
IGVkaXRpbmcvVGV4dEl0ZXJhdG9yLmNwcDoKKyAgICAgICAgKFdlYkNvcmU6OkJpdFN0YWNrOjpw
dXNoKToKKwogMjAwOS0wNi0xNiAgQnJlbnQgRnVsZ2hhbSAgPGJmdWxnaGFtQGdtYWlsLmNvbT4K
IAogICAgICAgICBSZXZpZXdlZCBieSBEYXJpbiBBZGxlci4KSW5kZXg6IFdlYkNvcmUvZWRpdGlu
Zy9UZXh0SXRlcmF0b3IuY3BwCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFdlYkNvcmUvZWRpdGluZy9UZXh0SXRl
cmF0b3IuY3BwCShyZXZpc2lvbiA0NDcyMykKKysrIFdlYkNvcmUvZWRpdGluZy9UZXh0SXRlcmF0
b3IuY3BwCSh3b3JraW5nIGNvcHkpCkBAIC0xMDksOCArMTA5LDEwIEBAIHZvaWQgQml0U3RhY2s6
OnB1c2goYm9vbCBiaXQpCiB7CiAgICAgdW5zaWduZWQgaW5kZXggPSBtX3NpemUgLyBiaXRzSW5X
b3JkOwogICAgIHVuc2lnbmVkIHNoaWZ0ID0gbV9zaXplICYgYml0SW5Xb3JkTWFzazsKLSAgICBp
ZiAoIXNoaWZ0ICYmIGluZGV4ID09IG1fd29yZHMuc2l6ZSgpKQorICAgIGlmICghc2hpZnQgJiYg
aW5kZXggPT0gbV93b3Jkcy5zaXplKCkpIHsKICAgICAgICAgbV93b3Jkcy5ncm93KGluZGV4ICsg
MSk7CisgICAgICAgIG1fd29yZHNbaW5kZXhdID0gMDsKKyAgICB9CiAgICAgdW5zaWduZWQmIHdv
cmQgPSBtX3dvcmRzW2luZGV4XTsKICAgICB1bnNpZ25lZCBtYXNrID0gMVUgPDwgc2hpZnQ7CiAg
ICAgaWYgKGJpdCkK
</data>
<flag name="review"
          id="16025"
          type_id="1"
          status="+"
          setter="fishd"
    />
          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>31355</attachid>
            <date>2009-06-16 11:15:32 -0700</date>
            <delta_ts>2009-06-16 12:50:11 -0700</delta_ts>
            <desc>v2</desc>
            <filename>umr-26449-2.diff</filename>
            <type>text/plain</type>
            <size>1266</size>
            <attacher name="Tony Chang">tony</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFdlYkNvcmUvQ2hhbmdlTG9n
CShyZXZpc2lvbiA0NDcyNCkKKysrIFdlYkNvcmUvQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBA
IC0xLDMgKzEsMTYgQEAKKzIwMDktMDYtMTYgIFRvbnkgQ2hhbmcgIDx0b255QGNocm9taXVtLm9y
Zz4KKworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMhKS4KKworICAgICAgICBXQVJO
SU5HOiBOTyBURVNUIENBU0VTIEFEREVEIE9SIENIQU5HRUQKKyAgICAgICAgCisgICAgICAgIEZp
eCBhIFVNUiBpbiBXZWJDb3JlOjpCaXRTdGFjayBieSBpbml0aWFsaXppbmcgbmV3IG1lbW9yeSB0
byAwLgorICAgICAgICBodHRwczovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/aWQ9MjY0
NDkKKyAgICAgICAgTm8gbmV3IHRlc3RzLCBjb3ZlcmVkIGJ5IHB1cmlmeS4KKworICAgICAgICAq
IGVkaXRpbmcvVGV4dEl0ZXJhdG9yLmNwcDoKKyAgICAgICAgKFdlYkNvcmU6OkJpdFN0YWNrOjpw
dXNoKToKKwogMjAwOS0wNi0xNiAgQnJlbnQgRnVsZ2hhbSAgPGJmdWxnaGFtQGdtYWlsLmNvbT4K
IAogICAgICAgICBSZXZpZXdlZCBieSBEYXJpbiBBZGxlci4KSW5kZXg6IFdlYkNvcmUvZWRpdGlu
Zy9UZXh0SXRlcmF0b3IuY3BwCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFdlYkNvcmUvZWRpdGluZy9UZXh0SXRl
cmF0b3IuY3BwCShyZXZpc2lvbiA0NDcyMykKKysrIFdlYkNvcmUvZWRpdGluZy9UZXh0SXRlcmF0
b3IuY3BwCSh3b3JraW5nIGNvcHkpCkBAIC0xMDksOCArMTA5LDEwIEBAIHZvaWQgQml0U3RhY2s6
OnB1c2goYm9vbCBiaXQpCiB7CiAgICAgdW5zaWduZWQgaW5kZXggPSBtX3NpemUgLyBiaXRzSW5X
b3JkOwogICAgIHVuc2lnbmVkIHNoaWZ0ID0gbV9zaXplICYgYml0SW5Xb3JkTWFzazsKLSAgICBp
ZiAoIXNoaWZ0ICYmIGluZGV4ID09IG1fd29yZHMuc2l6ZSgpKQorICAgIGlmICghc2hpZnQgJiYg
aW5kZXggPT0gbV93b3Jkcy5zaXplKCkpIHsKICAgICAgICAgbV93b3Jkcy5ncm93KGluZGV4ICsg
MSk7CisgICAgICAgIG1fd29yZHNbaW5kZXhdID0gMDsKKyAgICB9CiAgICAgdW5zaWduZWQmIHdv
cmQgPSBtX3dvcmRzW2luZGV4XTsKICAgICB1bnNpZ25lZCBtYXNrID0gMVUgPDwgc2hpZnQ7CiAg
ICAgaWYgKGJpdCkK
</data>
<flag name="review"
          id="16026"
          type_id="1"
          status="+"
          setter="fishd"
    />
          </attachment>
      

    </bug>

</bugzilla>