<?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>31475</bug_id>
          
          <creation_ts>2009-11-13 09:02:44 -0800</creation_ts>
          <short_desc>Crash in StringHash::equal due to unaligned string data</short_desc>
          <delta_ts>2010-04-06 07:46:57 -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>Critical</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Yong Li">yong.li.webkit</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>abarth</cc>
    
    <cc>ap</cc>
    
    <cc>darin</cc>
    
    <cc>dave+webkit</cc>
    
    <cc>hausmann</cc>
    
    <cc>joenotcharles</cc>
    
    <cc>levin</cc>
    
    <cc>staikos</cc>
    
    <cc>steveblock</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>163331</commentid>
    <comment_count>0</comment_count>
    <who name="Yong Li">yong.li.webkit</who>
    <bug_when>2009-11-13 09:02:44 -0800</bug_when>
    <thetext>We&apos;ve found a cash on espn.go.com. The reason is:

1. StringHash::equal assumes String::characters() is aligned to 4-byte boundary.

2. When PassRefPtr&lt;StringImpl&gt; StringImpl::create(const JSC::UString&amp; str) uses shared buffer with UString, m_data is not guaranteed to be 4-byte aligned.
because UString::Rep::data() can point to any offset of the internal buffer.

The solution that Dave Tapuska suggests is: When UString::data() is not aligned to 4-byte, we just don&apos;t use the shared buffer.

Anyone please give some comments?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>163432</commentid>
    <comment_count>1</comment_count>
    <who name="David Levin">levin</who>
    <bug_when>2009-11-13 12:20:48 -0800</bug_when>
    <thetext>&gt; The solution that Dave Tapuska suggests is: When UString::data() is not aligned
&gt; to 4-byte, we just don&apos;t use the shared buffer.
&gt; 
&gt; Anyone please give some comments?

Tricky. I created this bug unfortunately.

I can see at least two solutions:
1. Dave Tapuska;s suggestion.
2. Change StringHash::Equal to use memcmp

You could try each solution separately in a ship build and run drameo and see which has less of a perf impact. 

I suspect that #1 is the better option.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>163439</commentid>
    <comment_count>2</comment_count>
    <who name="Yong Li">yong.li.webkit</who>
    <bug_when>2009-11-13 12:27:49 -0800</bug_when>
    <thetext>(In reply to comment #1)
&gt; &gt; The solution that Dave Tapuska suggests is: When UString::data() is not aligned
&gt; &gt; to 4-byte, we just don&apos;t use the shared buffer.
&gt; &gt; 
&gt; &gt; Anyone please give some comments?
&gt; 
&gt; Tricky. I created this bug unfortunately.
&gt; 
&gt; I can see at least two solutions:
&gt; 1. Dave Tapuska;s suggestion.
&gt; 2. Change StringHash::Equal to use memcmp
&gt; 
&gt; You could try each solution separately in a ship build and run drameo and see
&gt; which has less of a perf impact. 
&gt; 
&gt; I suspect that #1 is the better option.

Yeah, that&apos;s what we tried, and either way can fix the problem. But we haven&apos;t run any performance test so far. BTW, the performance affect may rely on platform/compiler. memcmp (or wmemcmp?) could probably be optimized with some inline code by compiler.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>163456</commentid>
    <comment_count>3</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2009-11-13 12:54:36 -0800</bug_when>
    <thetext>It&apos;s easy to make an alternate StringHash::equal in a way that does not depend on type punning in a non-portable way. The performance  optimization of comparing four bytes at a time is not needed just to have WebKit. So I suggest starting by changing StringHash::equal to only do the optimization on platforms where it is safe.

The other question, though, is whether the unaligned strings are having some sort of performance cost on platforms where the optimization is safe.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>163458</commentid>
    <comment_count>4</comment_count>
    <who name="Joe Mason">joenotcharles</who>
    <bug_when>2009-11-13 12:58:56 -0800</bug_when>
    <thetext>This thread discusses the issue, but it seems their conclusion was never adopted:

http://lists.macosforge.org/pipermail/webkit-dev/2009-July/008630.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>163463</commentid>
    <comment_count>5</comment_count>
    <who name="Yong Li">yong.li.webkit</who>
    <bug_when>2009-11-13 13:13:57 -0800</bug_when>
    <thetext>Another thing about StringImpl (not related to this bug):

newUCharVector() is defined, but never used. deleteUCharVector() is used, but I don&apos;t think it ever gets called because m_data is never a standalone memory block.

So need some cleanup. Probably I should raise another bug for that?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>163523</commentid>
    <comment_count>6</comment_count>
      <attachid>43204</attachid>
    <who name="David Tapuska">dave+webkit</who>
    <bug_when>2009-11-13 14:25:31 -0800</bug_when>
    <thetext>Created attachment 43204
Apply defines to StringHash::Equal</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>163606</commentid>
    <comment_count>7</comment_count>
      <attachid>43204</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2009-11-13 17:24:13 -0800</bug_when>
    <thetext>Comment on attachment 43204
Apply defines to StringHash::Equal

Rejecting patch 43204 from commit-queue.

Failed to run &quot;[&apos;WebKitTools/Scripts/run-webkit-tests&apos;, &apos;--no-launch-safari&apos;, &apos;--quiet&apos;, &apos;--exit-after-n-failures=1&apos;]&quot; exit_code: 1
Running build-dumprendertree
Running tests from /Users/eseidel/Projects/CommitQueue/LayoutTests
Testing 11623 test cases.
http/tests/xmlhttprequest/workers/shared-worker-close.html -&gt; crashed

Exiting early after 1 failures. 9309 tests run.
363.31s total testing time

9308 test cases (99%) succeeded
1 test case (&lt;1%) crashed
5 test cases (&lt;1%) had stderr output</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>163799</commentid>
    <comment_count>8</comment_count>
      <attachid>43204</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2009-11-15 15:34:17 -0800</bug_when>
    <thetext>Comment on attachment 43204
Apply defines to StringHash::Equal

Clearing flags on attachment: 43204

Committed r51006: &lt;http://trac.webkit.org/changeset/51006&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>163800</commentid>
    <comment_count>9</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2009-11-15 15:34:24 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>165487</commentid>
    <comment_count>10</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2009-11-20 16:07:43 -0800</bug_when>
    <thetext>*** Bug 31726 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>209044</commentid>
    <comment_count>11</comment_count>
    <who name="Simon Hausmann">hausmann</who>
    <bug_when>2010-04-06 07:46:57 -0700</bug_when>
    <thetext>Cherry-picked into QtWebKit for Qt 4.6 with commit e3dc4ef2b801d91e115c54f833fa7766d392ceda</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>43204</attachid>
            <date>2009-11-13 14:25:31 -0800</date>
            <delta_ts>2009-11-15 15:34:17 -0800</delta_ts>
            <desc>Apply defines to StringHash::Equal</desc>
            <filename>StringHash.patch</filename>
            <type>text/plain</type>
            <size>2150</size>
            <attacher name="David Tapuska">dave+webkit</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1dlYkNvcmUvcGxhdGZvcm0vdGV4dC9TdHJpbmdIYXNoLmggYi9XZWJDb3Jl
L3BsYXRmb3JtL3RleHQvU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