https://bugs.ruby-lang.org/
https://bugs.ruby-lang.org/favicon.ico?1711330511
2016-07-02T15:38:47Z
Ruby Issue Tracking System
Ruby master - Bug #12509: Using qsort_s in mingw-w64 causes failures
https://bugs.ruby-lang.org/issues/12509?journal_id=59468
2016-07-02T15:38:47Z
moritat (Tsuyoshi Morita)
<ul><li><strong>File</strong> <a href="/attachments/6046">configure.in.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/6046/configure.in.patch">configure.in.patch</a> added</li></ul><p>I confirmed that the failures 1) to 8) are same as<br>
VS2010 with '#define HAVE_QSORT_S'.<br>
I suppose 9) to 11) are skipped for VS2010.</p>
<p>Since mingw* uses the msvcrt runtime, I propose<br>
disabling use of qsort_s for mingw*, too.</p>
Ruby master - Bug #12509: Using qsort_s in mingw-w64 causes failures
https://bugs.ruby-lang.org/issues/12509?journal_id=60505
2016-09-14T14:13:07Z
moritat (Tsuyoshi Morita)
<ul><li><strong>ruby -v</strong> changed from <i>ruby 2.4.0preview1 (2016-06-20 trunk 55466) [x64-mingw32]</i> to <i>ruby 2.4.0dev (2016-09-14 trunk 56160) [x64-mingw32]</i></li></ul><p>Could you take in the attached patch before 2.4.0 release ?<br>
These keep fail in the current trunk version.</p>
Ruby master - Bug #12509: Using qsort_s in mingw-w64 causes failures
https://bugs.ruby-lang.org/issues/12509?journal_id=60820
2016-10-11T07:09:22Z
shyouhei (Shyouhei Urabe)
shyouhei@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>nobu (Nobuyoshi Nakada)</i></li></ul>
Ruby master - Bug #12509: Using qsort_s in mingw-w64 causes failures
https://bugs.ruby-lang.org/issues/12509?journal_id=60870
2016-10-12T15:39:15Z
nobu (Nobuyoshi Nakada)
nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li></ul><p>Applied in changeset r56410.</p>
<hr>
<p>test_array.rb: do not assume stable sort</p>
<ul>
<li>test/ruby/test_array.rb (test_sort_bang_with_freeze): make a<br>
clone to copy a <=> singleton method, instead of dup. which<br>
element will be called is not predictable.<br>
<a href="/issues/12509">[ruby-core:76088]</a> [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Using qsort_s in mingw-w64 causes failures (Closed)" href="https://bugs.ruby-lang.org/issues/12509">#12509</a>]</li>
</ul>
Ruby master - Bug #12509: Using qsort_s in mingw-w64 causes failures
https://bugs.ruby-lang.org/issues/12509?journal_id=60871
2016-10-12T15:48:04Z
nobu (Nobuyoshi Nakada)
nobu@ruby-lang.org
<ul></ul><p>This is because <code>Array#sort</code> and <code>Array#sort_by</code> may not be stable.<br>
I fixed <code>test_array.rb</code> and reported to rubygems, but uncertain the rest, whether rexml and rss expect stable sort, or the orders are undefined and the tests have bugs.</p>
<p>A patch to fix the tests.</p>
<pre><code class="diff syntaxhl" data-language="diff"><span class="gh">diff --git i/test/rexml/xpath/test_text.rb w/test/rexml/xpath/test_text.rb
index cea3b05..7222388 100644
</span><span class="gd">--- i/test/rexml/xpath/test_text.rb
</span><span class="gi">+++ w/test/rexml/xpath/test_text.rb
</span><span class="p">@@ -69,7 +69,9 @@</span>
assert_equal(1, nodes.size, "<b> has one element ancestor")
nodes = @doc.get_elements('//b/ancestor::node()')
assert_equal(2, nodes.size, "<b> has two node ancestors")
<span class="gd">- assert_kind_of REXML::Document, nodes[1]
</span><span class="gi">+ nodes.sort_by!(&:name)
+ assert_kind_of REXML::Document, nodes[0]
+ assert_kind_of REXML::Element, nodes[1]
</span> end
end
end
<span class="gh">diff --git i/test/rss/test_maker_0.9.rb w/test/rss/test_maker_0.9.rb
index 64d04bc..d07a724 100644
</span><span class="gd">--- i/test/rss/test_maker_0.9.rb
</span><span class="gi">+++ w/test/rss/test_maker_0.9.rb
</span><span class="p">@@ -315,6 +315,7 @@</span>
assert_equal(link, item.link)
assert_nil(item.description)
<span class="gi">+ pubDate = Time.now
</span>
item_size = 5
rss = RSS::Maker.make("0.91") do |maker|
<span class="p">@@ -325,6 +326,7 @@</span>
_item.title = "#{title}#{i}"
_item.link = "#{link}#{i}"
_item.description = "#{description}#{i}"
<span class="gi">+ _item.date = pubDate - i
</span> end
end
maker.items.do_sort = true
<span class="gh">diff --git i/test/rss/test_maker_1.0.rb w/test/rss/test_maker_1.0.rb
index c8f9977..f3c0e50 100644
</span><span class="gd">--- i/test/rss/test_maker_1.0.rb
</span><span class="gi">+++ w/test/rss/test_maker_1.0.rb
</span><span class="p">@@ -269,6 +269,7 @@</span>
assert_equal(link, item.link)
assert_nil(item.description)
<span class="gi">+ pubDate = Time.now
</span>
item_size = 5
rss = RSS::Maker.make("1.0") do |maker|
<span class="p">@@ -279,6 +280,7 @@</span>
_item.title = "#{title}#{i}"
_item.link = "#{link}#{i}"
_item.description = "#{description}#{i}"
<span class="gi">+ _item.date = pubDate - i
</span> end
end
maker.items.do_sort = true
<span class="gh">diff --git i/test/rss/test_maker_2.0.rb w/test/rss/test_maker_2.0.rb
index 8528611..f6d83f0 100644
</span><span class="gd">--- i/test/rss/test_maker_2.0.rb
</span><span class="gi">+++ w/test/rss/test_maker_2.0.rb
</span><span class="p">@@ -390,7 +390,7 @@</span>
item.description = "#{description}#{i}"
item.author = "#{author}#{i}"
item.comments = "#{comments}#{i}"
<span class="gd">- item.date = pubDate
</span><span class="gi">+ item.date = pubDate - i
</span> end
end
maker.items.do_sort = true
<span class="p">@@ -402,8 +402,8 @@</span>
assert_equal("#{description}#{i}", item.description)
assert_equal("#{author}#{i}", item.author)
assert_equal("#{comments}#{i}", item.comments)
<span class="gd">- assert_equal(pubDate, item.pubDate)
- assert_equal(pubDate, item.date)
</span><span class="gi">+ assert_equal(pubDate - i, item.pubDate)
+ assert_equal(pubDate - i, item.date)
</span> end
rss = RSS::Maker.make("2.0") do |maker|
</code></pre>
Ruby master - Bug #12509: Using qsort_s in mingw-w64 causes failures
https://bugs.ruby-lang.org/issues/12509?journal_id=60878
2016-10-13T01:52:21Z
nobu (Nobuyoshi Nakada)
nobu@ruby-lang.org
<ul></ul><p>Or a patch for stable sort.</p>
<pre><code class="diff syntaxhl" data-language="diff"><span class="gh">diff --git i/lib/rexml/xpath_parser.rb w/lib/rexml/xpath_parser.rb
index 181b2b6..7ae6495 100644
</span><span class="gd">--- i/lib/rexml/xpath_parser.rb
</span><span class="gi">+++ w/lib/rexml/xpath_parser.rb
</span><span class="p">@@ -503,9 +503,9 @@</span>
node_idx << np.parent.index( np )
np = np.parent
end
<span class="gd">- new_arry << [ node_idx.reverse, node ]
</span><span class="gi">+ new_arry << [ node_idx.reverse, new_arry.size, node ]
</span> }
<span class="gd">- new_arry.sort{ |s1, s2| s1[0] <=> s2[0] }.collect{ |s| s[1] }
</span><span class="gi">+ new_arry.sort.collect(&:last)
</span> end
<span class="gh">diff --git i/lib/rss/maker/base.rb w/lib/rss/maker/base.rb
index bc4ca84..8c00375 100644
</span><span class="gd">--- i/lib/rss/maker/base.rb
</span><span class="gi">+++ w/lib/rss/maker/base.rb
</span><span class="p">@@ -690,13 +690,15 @@</span>
private
def sort_if_need
if @do_sort.respond_to?(:call)
<span class="gd">- @items.sort do |x, y|
- @do_sort.call(x, y)
- end
</span><span class="gi">+ @items.map.with_index.sort do |(x, xi), (y, yi)|
+ c = @do_sort.call(x, y)
+ c == 0 ? xi <=> yi : c
+ end.map(&:first)
</span> elsif @do_sort
<span class="gd">- @items.sort do |x, y|
- y <=> x
- end
</span><span class="gi">+ @items.map.with_index.sort do |(x, xi), (y, yi)|
+ c = y <=> x
+ c == 0 ? xi <=> yi : c
+ end.map(&:first)
</span> else
@items
end
</code></pre>