Bug #8518

assertion failed in rb_ary_sort_bang

Added by Kazuhiro NISHIYAMA over 1 year ago. Updated over 1 year ago.

[ruby-dev:47419]
Status:Closed
Priority:Normal
Assignee:Nobuyoshi Nakada
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/test_array.rb の test_sort! の以下に相当する部分で 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: rb_ary_sort_bang: Assertion `!(((!((!(((VALUE)((ary)) & RUBY_IMMEDIATE_MASK) || !!(((VALUE)((ary)) & ~((VALUE)RUBY_Qnil)) == 0)) && (int)(((struct RBasic*)((ary)))->flags & RUBY_T_MASK) != RUBY_T_NODE)?(((struct RBasic*)(((ary))))->flags&(((((VALUE)1)<<(12+2))))):0) || !((!(((VALUE)((ary)) & RUBY_IMMEDIATE_MASK) || !!(((VALUE)((ary)) & ~((VALUE)RUBY_Qnil)) == 0)) && (int)(((struct RBasic*)((ary)))->flags & RUBY_T_MASK) != RUBY_T_NODE)?(((struct RBasic*)(((ary))))->flags&(((((VALUE)1)<<(12+1))))):0)) ? (void) (0) : assert_fail ("!((!(((VALUE)((ary)) & RUBY_IMMEDIATE_MASK) || !!(((VALUE)((ary)) & ~((VALUE)RUBY_Qnil)) == 0)) && (int)(((struct RBasic*)((ary)))->flags & RUBY_T_MASK) != RUBY_T_NODE)?(((struct RBasic*)(((ary))))->flags&(((((VALUE)1)<<(12+2))))):0) || !((!(((VALUE)((ary)) & RUBY_IMMEDIATE_MASK) || !!(((VALUE)((ary)) & ~((VALUE)RUBY_Qnil)) == 0)) && (int)(((struct RBasic*)((ary)))->flags & RUBY_T_MASK) != RUBY_T_NODE)?(((struct RBasic*)(((ary))))->flags&(((((VALUE)1)<<(12+1))))):0)", "/home/kazu/z/wc/CI/ruby/array.c", 2336, __PRETTY_FUNCTION)), ((!(((VALUE)((ary)) & RUBY_IMMEDIATE_MASK) || !!(((VALUE)((ary)) & ~((VALUE)RUBY_Qnil)) == 0)) && (int)(((struct RBasic*)((ary)))->flags & RUBY_T_MASK) != RUBY_T_NODE)?(((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 over 1 year ago

array.c: fix false assertions

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

Revision 41253
Added by Nobuyoshi Nakada over 1 year ago

array.c: fix false assertions

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

History

#1 Updated by Nobuyoshi Nakada over 1 year 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 (rb_ary_sort_bang): remove duplicated assertions. ARY_HEAP_PTR() implies ary not to be embedded. [Bug #8518]

Also available in: Atom PDF