<?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>13147</bug_id>
          
          <creation_ts>2007-03-21 13:04:17 -0700</creation_ts>
          <short_desc>RenderTableCell::sortBorderStyles does not meet qsort&apos;s contract</short_desc>
          <delta_ts>2010-09-22 03:16:41 -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>CSS</component>
          <version>523.x (Safari 3)</version>
          <rep_platform>All</rep_platform>
          <op_sys>OS X 10.4</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>39966</dup_id>
          
          <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="Patrick">phanna</reporter>
          <assigned_to name="Dave Hyatt">hyatt</assigned_to>
          <cc>steveblock</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>17928</commentid>
    <comment_count>0</comment_count>
    <who name="Patrick">phanna</who>
    <bug_when>2007-03-21 13:04:17 -0700</bug_when>
    <thetext>When sorting CollapsedBorderStyles with qsort, the comparator function (compareBorderStylesForQSort) does not honor the requirement that cmp(a, b) == cmp(b, a). This does not appear for the qsort implementation on the Mac but if you use a bubblesort instead of qsort, the problem appears.

The issue is that two borders differ only by color and so compareBorders() returns the first parameter each time it is called. This means that calling compareBorders(a, b) != compareBorders(b, a) and thus compareBorderStylesForQSort(a, b) != compareBorderStylesForQSort(b, a) and so an infinite loop can occur because the sorting algorithm will constantly swap the two values.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>17921</commentid>
    <comment_count>1</comment_count>
      <attachid>13748</attachid>
    <who name="Dave Hyatt">hyatt</who>
    <bug_when>2007-03-21 14:00:46 -0700</bug_when>
    <thetext>Created attachment 13748
Patch to use a stable sort instead.

This patch switching border style comparison to use a stable sort instead.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>17667</commentid>
    <comment_count>2</comment_count>
    <who name="Patrick">phanna</who>
    <bug_when>2007-03-22 10:08:05 -0700</bug_when>
    <thetext>stable_sort will work but it is not the correct solution. A better solution is to fix the comparison function so that a &lt; b =&gt; b &gt; a.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>282872</commentid>
    <comment_count>3</comment_count>
    <who name="Steve Block">steveblock</who>
    <bug_when>2010-09-22 03:16:41 -0700</bug_when>
    <thetext>It looks to me like this is fixed with http://trac.webkit.org/changeset/67862 (https://bugs.webkit.org/show_bug.cgi?id=39966) as compareBorders() now returns 0 in the case when borders differ only in colour.

&gt; if (border1.precedence() == border2.precedence()) 
&gt;     return 0;

*** This bug has been marked as a duplicate of bug 39966 ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>13748</attachid>
            <date>2007-03-21 14:00:46 -0700</date>
            <delta_ts>2010-06-10 14:30:07 -0700</delta_ts>
            <desc>Patch to use a stable sort instead.</desc>
            <filename>patch.txt</filename>
            <type>text/plain</type>
            <size>1370</size>
            <attacher name="Dave Hyatt">hyatt</attacher>
            
              <data encoding="base64">SW5kZXg6IHJlbmRlcmluZy9SZW5kZXJUYWJsZUNlbGwuY3BwCj09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIHJlbmRl
cmluZy9SZW5kZXJUYWJsZUNlbGwuY3BwCShyZXZpc2lvbiAyMDI2OCkKKysrIHJlbmRlcmluZy9S
ZW5kZXJU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