Bug #8518

assertion failed in rb_ary_sort_bang

Added by Kazuhiro NISHIYAMA 10 months ago. Updated 10 months ago.

[ruby-dev:47419]
Status:Closed
Priority:Normal
Assignee:Nobuyoshi Nakada
Category:core
Target version:2.1.0
ruby -v:ruby 2.1.0dev (2013-06-12 trunk 41248) [x86_64-linux] Backport:1.9.3: UNKNOWN, 2.0.0: UNKNOWN

Description

-DARRAY_DEBUG の続きです。

test/ruby/testarray.rb の testsort! の以下に相当する部分で assertion failed になります。

% ./miniruby -e 'a=Array[4, 1, 2, 3]; a.sort! {|m, n| a.replace([9, 8, 7]); m <=> n }'
miniruby: .../ruby/array.c:2336: rbarysortbang: Assertion `!(((!((!(((VALUE)((ary)) & RUBYIMMEDIATEMASK) || !!(((VALUE)((ary)) & ~((VALUE)RUBYQnil)) == 0)) && (int)(((struct RBasic)((ary)))->flags & RUBYTMASK) != RUBYTNODE)?(((struct RBasic)(((ary))))->flags&(((((VALUE)1)<<(12+2))))):0) || !((!(((VALUE)((ary)) & RUBYIMMEDIATEMASK) || !!(((VALUE)((ary)) & ~((VALUE)RUBYQnil)) == 0)) && (int)(((struct RBasic*)((ary)))->flags & RUBYTMASK) != RUBYTNODE)?(((struct RBasic*)(((ary))))->flags&(((((VALUE)1)<<(12+1))))):0)) ? (void) (0) : _assertfail ("!((!(((VALUE)((ary)) & RUBYIMMEDIATEMASK) || !!(((VALUE)((ary)) & ~((VALUE)RUBYQnil)) == 0)) && (int)(((struct RBasic)((ary)))->flags & RUBYTMASK) != RUBYTNODE)?(((struct RBasic)(((ary))))->flags&(((((VALUE)1)<<(12+2))))):0) || !((!(((VALUE)((ary)) & RUBYIMMEDIATEMASK) || !!(((VALUE)((ary)) & ~((VALUE)RUBYQnil)) == 0)) && (int)(((struct RBasic*)((ary)))->flags & RUBYTMASK) != RUBYTNODE)?(((struct RBasic*)(((ary))))->flags&(((((VALUE)1)<<(12+1))))):0)", "/home/kazu/z/wc/CI/ruby/array.c", 2336, _PRETTYFUNCTION)), ((!(((VALUE)((ary)) & RUBYIMMEDIATEMASK) || !!(((VALUE)((ary)) & ~((VALUE)RUBYQnil)) == 0)) && (int)(((struct RBasic)((ary)))->flags & RUBYTMASK) != RUBYTNODE)?(((struct RBasic)(((ary))))->flags&(((((VALUE)1)<<(12+1))))):0)!=0)' failed.

なぜか行番号がずれていて 2336 行目は以下の if 文の行ですが、その下の ary の方がひっかかっているようです。

        assert(!ARY_EMBED_P(tmp));
        if (ARY_HEAP_PTR(ary) == ARY_HEAP_PTR(tmp)) {
            assert(!ARY_EMBED_P(ary));

Associated revisions

Revision 41253
Added by Nobuyoshi Nakada 11 months ago

array.c: fix false assertions

  • array.c (rbarysortbang): remove duplicated assertions. ARYHEAP_PTR() implies ary not to be embedded. [Bug #8518]

History

#1 Updated by Nobuyoshi Nakada 10 months ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r41253.
Kazuhiro, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


array.c: fix false assertions

  • array.c (rbarysortbang): remove duplicated assertions. ARYHEAP_PTR() implies ary not to be embedded. [Bug #8518]

Also available in: Atom PDF