From: nobu@... Date: 2016-10-13T01:52:21+00:00 Subject: [ruby-core:77609] [Ruby trunk Bug#12509] Using qsort_s in mingw-w64 causes failures Issue #12509 has been updated by Nobuyoshi Nakada. Or a patch for stable sort. ```diff diff --git i/lib/rexml/xpath_parser.rb w/lib/rexml/xpath_parser.rb index 181b2b6..7ae6495 100644 --- i/lib/rexml/xpath_parser.rb +++ w/lib/rexml/xpath_parser.rb @@ -503,9 +503,9 @@ node_idx << np.parent.index( np ) np = np.parent end - new_arry << [ node_idx.reverse, node ] + new_arry << [ node_idx.reverse, new_arry.size, node ] } - new_arry.sort{ |s1, s2| s1[0] <=> s2[0] }.collect{ |s| s[1] } + new_arry.sort.collect(&:last) end diff --git i/lib/rss/maker/base.rb w/lib/rss/maker/base.rb index bc4ca84..8c00375 100644 --- i/lib/rss/maker/base.rb +++ w/lib/rss/maker/base.rb @@ -690,13 +690,15 @@ private def sort_if_need if @do_sort.respond_to?(:call) - @items.sort do |x, y| - @do_sort.call(x, y) - end + @items.map.with_index.sort do |(x, xi), (y, yi)| + c = @do_sort.call(x, y) + c == 0 ? xi <=> yi : c + end.map(&:first) elsif @do_sort - @items.sort do |x, y| - y <=> x - end + @items.map.with_index.sort do |(x, xi), (y, yi)| + c = y <=> x + c == 0 ? xi <=> yi : c + end.map(&:first) else @items end ``` ---------------------------------------- Bug #12509: Using qsort_s in mingw-w64 causes failures https://bugs.ruby-lang.org/issues/12509#change-60878 * Author: Tsuyoshi Morita * Status: Closed * Priority: Normal * Assignee: Nobuyoshi Nakada * ruby -v: ruby 2.4.0dev (2016-09-14 trunk 56160) [x64-mingw32] * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- I got failures related to 'qsort_s'. The following failures will disappear when I delete AC_CHECK_FUNCS(qsort_s) code in configure. ~~~ 1) Failure: REXMLTests::TestXPathText#test_ancestors [C:/msys64/home/tsuyoshi/ruby-2.4.0-preview1/test/rexml/xpath/test_text.rb:72]: Failed assertion, no message given. 2) Failure: RSS::TestMaker09#test_items [C:/msys64/home/tsuyoshi/ruby-2.4.0-preview1/test/rss/test_maker_0.9.rb:336]: <"TITLE0"> expected but was <"TITLE1">. 3) Failure: RSS::TestMaker09#test_items_with_new_api_since_018 [C:/msys64/home/tsuyoshi/ruby-2.4.0-preview1/test/rss/test_maker_0.9.rb:336]: <"TITLE0"> expected but was <"TITLE1">. 4) Failure: RSS::TestMaker10#test_items [C:/msys64/home/tsuyoshi/ruby-2.4.0-preview1/test/rss/test_maker_1.0.rb:288]: <"http://hoge.com/0"> expected but was <"http://hoge.com/1">. 5) Failure: RSS::TestMaker10#test_items_with_new_api_since_018 [C:/msys64/home/tsuyoshi/ruby-2.4.0-preview1/test/rss/test_maker_1.0.rb:288]: <"http://hoge.com/0"> expected but was <"http://hoge.com/1">. 6) Failure: RSS::TestMaker20#test_items [C:/msys64/home/tsuyoshi/ruby-2.4.0-preview1/test/rss/test_maker_2.0.rb:400]: <"TITLE0"> expected but was <"TITLE1">. 7) Failure: RSS::TestMaker20#test_items_with_new_api_since_018 [C:/msys64/home/tsuyoshi/ruby-2.4.0-preview1/test/rss/test_maker_2.0.rb:400]: <"TITLE0"> expected but was <"TITLE1">. 8) Failure: TestArray#test_sort_bang_with_freeze [C:/msys64/home/tsuyoshi/ruby-2.4.0-preview1/test/ruby/test_array.rb:1470]: frozen during comparison. [RuntimeError] exception expected, not. Class: Message: <"comparison of Object with Object failed"> ---Backtrace--- C:/msys64/home/tsuyoshi/ruby-2.4.0-preview1/test/ruby/test_array.rb:1470:in `sort!' C:/msys64/home/tsuyoshi/ruby-2.4.0-preview1/test/ruby/test_array.rb:1470:in `block in test_sort_bang_with_freeze' C:/msys64/home/tsuyoshi/ruby-2.4.0-preview1/test/lib/test/unit/assertions.rb:74:in `assert_raise' C:/msys64/home/tsuyoshi/ruby-2.4.0-preview1/test/ruby/test_array.rb:1470:in `test_sort_bang_with_freeze' C:/msys64/home/tsuyoshi/ruby-2.4.0-preview1/test/lib/test/unit.rb:1027:in `run_test' --------------- 9) Failure: TestGemRequestSetLockfile#test_to_s_gem_dependency_non_default [C:/msys64/home/tsuyoshi/ruby-2.4.0-preview1/test/rubygems/test_gem_request_set_lockfile.rb:239]: --- expected +++ actual @@ -10,5 +10,5 @@ DEPENDENCIES a - b + b (>= 1) " 10) Failure: TestGemResolver#test_raises_dependency_error [C:/msys64/home/tsuyoshi/ruby-2.4.0-preview1/test/rubygems/test_gem_resolver.rb:425]: --- expected +++ actual @@ -1,2 +1,2 @@ -[Gem::Dependency.new("c", Gem::Requirement.new(["= 2"]), :runtime), - Gem::Dependency.new("c", Gem::Requirement.new(["= 1"]), :runtime)] +[Gem::Dependency.new("c", Gem::Requirement.new(["= 1"]), :runtime), + Gem::Dependency.new("c", Gem::Requirement.new(["= 2"]), :runtime)] 11) Failure: TestGemResolver#test_raises_when_possibles_are_exhausted [C:/msys64/home/tsuyoshi/ruby-2.4.0-preview1/test/rubygems/test_gem_resolver.rb:524]: Expected: "c-2" Actual: "c-1" ~~~ $ gcc -v Using built-in specs. COLLECT_GCC=C:\msys64\mingw64\bin\gcc.exe COLLECT_LTO_WRAPPER=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.4.0/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../gcc-5.4.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --with-gxx-include-dir=/mingw64/include/c++/5.4.0 --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,objc,obj-c++,fortran,ada --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-version-specific-runtime-libs --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='R ev1, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld Thread model: posix gcc version 5.4.0 (Rev1, Built by MSYS2 project) ---Files-------------------------------- configure.in.patch (393 Bytes) -- https://bugs.ruby-lang.org/ Unsubscribe: