Project

General

Profile

Actions

Bug #12876

closed

Calling new hangs Ruby when class prepends an empty module and makes initialize method public

Added by floehopper (James Mead) about 8 years ago. Updated about 8 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.0.0p648 and ruby 2.1.3p242 onwards
[ruby-core:77784]

Description

module Foo
end

class Bar
  prepend Foo

  public :initialize
end

p Bar.new # => hangs

Runs OK

  • ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin14.0]
  • ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin14.0]
  • ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin14.0]
  • rubinius 3.33 (2.2.2 db6f477e 2016-05-23 3.8.1) [x86_64-darwin14.5.0]

Hangs on last line

  • ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-darwin14.5.0]
  • ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-darwin14.0]
  • ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]
  • ruby 2.1.10p492 (2016-04-01 revision 54464) [x86_64-darwin14.0]
  • ruby 2.2.5p319 (2016-04-26 revision 54774) [x86_64-darwin14]
  • ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin14]
  • ruby 2.4.0preview2 (2016-09-09 trunk 56129) [x86_64-darwin14]

This might be related to Bug #12832, although in this case it is possible to interrupt with ctrl-C and the problem exists in Ruby v2.0.0 as well as v2.1.3 onwards.


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #12920: Strange NoMethodError in Time.nowClosedActions

Updated by shyouhei (Shyouhei Urabe) about 8 years ago

  • Status changed from Open to Assigned
  • Assignee set to ko1 (Koichi Sasada)
zsh % lldb -- ./miniruby -v ~/tmp.rb
(lldb) target create "./miniruby"
Current executable set to './miniruby' (x86_64).
(lldb) settings set -- target.run-args  "-v" "/Users/urabe.shyouhei/tmp.rb"
(lldb) run
Process 98447 launched: './miniruby' (x86_64)
ruby 2.4.0dev (2016-10-27 trunk 56506) [x86_64-darwin15]
Process 98447 stopped
* thread #1: tid = 0x42e6d, 0x00000001001f1b4c miniruby`rb_callable_method_entry + 19 at vm_method.c:806, stop reason = signal SIGSTOP
    frame #0: 0x00000001001f1b4c miniruby`rb_callable_method_entry + 19 at vm_method.c:806
   803      struct rb_id_table *mtbl;
   804      const rb_callable_method_entry_t *cme;
   805
-> 806      if (me && me->defined_class == 0) {
   807          VM_ASSERT(RB_TYPE_P(defined_class, T_ICLASS) || RB_TYPE_P(defined_class, T_MODULE));
   808          VM_ASSERT(me->defined_class == 0);
   809
(lldb) bt
* thread #1: tid = 0x42e6d, 0x00000001001f1b4c miniruby`rb_callable_method_entry + 19 at vm_method.c:806, stop reason = signal SIGSTOP
  * frame #0: 0x00000001001f1b4c miniruby`rb_callable_method_entry + 19 at vm_method.c:806
    frame #1: 0x00000001001f1b39 miniruby`rb_callable_method_entry(klass=<unavailable>, id=3105) + 25
    frame #2: 0x00000001002007dd miniruby`vm_call0_body(th=0x00000001005064d0, calling=0x00007fff5fbfd450, ci=0x00007fff5fbfd440, cc=<unavailable>, argv=0x0000000100700040) + 1021 at vm_eval.c:206
    frame #3: 0x0000000100200e7d miniruby`rb_call0 + 189 at vm_eval.c:61
    frame #4: 0x0000000100200e47 miniruby`rb_call0(recv=4303747680, mid=3105, argc=0, argv=0x0000000100700040, scope=CALL_FCALL, self=<unavailable>) + 135
    frame #5: 0x00000001000f3f41 miniruby`rb_class_new_instance(argc=0, argv=0x0000000100700040, klass=<unavailable>) + 33 at object.c:1880
    frame #6: 0x00000001001f0ca6 miniruby`vm_call_cfunc + 184 at vm_insnhelper.c:1752
    frame #7: 0x00000001001f0bee miniruby`vm_call_cfunc(th=0x00000001005064d0, reg_cfp=0x00000001007fffa0, calling=<unavailable>, ci=<unavailable>, cc=<unavailable>) + 46
    frame #8: 0x00000001001feeae miniruby`vm_call_method_each_type(th=0x00000001005064d0, cfp=0x00000001007fffa0, calling=0x00007fff5fbfd700, ci=<unavailable>, cc=<unavailable>) + 142 at vm_insnhelper.c:2138
    frame #9: 0x00000001001ff40b miniruby`vm_call_method(th=0x00000001005064d0, cfp=0x00000001007fffa0, calling=<unavailable>, ci=<unavailable>, cc=<unavailable>) + 235 at vm_insnhelper.c:2288
    frame #10: 0x00000001001f8349 miniruby`vm_exec_core(th=0x00000001005064d0, initial=<unavailable>) + 5961 at insns.def:1066
    frame #11: 0x00000001001fd94a miniruby`vm_exec(th=0x00000001005064d0) + 138 at vm.c:1711
    frame #12: 0x00000001000826e0 miniruby`ruby_exec_internal(n=0x0000000100864330) + 176 at eval.c:244
    frame #13: 0x000000010008638f miniruby`ruby_run_node [inlined] ruby_exec_node(n=<unavailable>) + 47 at eval.c:308
    frame #14: 0x000000010008637b miniruby`ruby_run_node(n=<unavailable>) + 27
    frame #15: 0x000000010021759e miniruby`main(argc=<unavailable>, argv=<unavailable>) + 78 at main.c:36
    frame #16: 0x00007fff8e0db5ad libdyld.dylib`start + 1
(lldb)
Actions #2

Updated by nobu (Nobuyoshi Nakada) about 8 years ago

  • Status changed from Assigned to Closed

Applied in changeset r56520.


vm_eval.c: follow the original class

  • vm_eval.c (vm_call0_body): follow the original class, not to
    loop the prepended module. [ruby-core:77784] [Bug #12876]

Updated by nagachika (Tomoyuki Chikanaga) about 8 years ago

  • Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED

Updated by nagachika (Tomoyuki Chikanaga) about 8 years ago

  • Backport changed from 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED to 2.1: REQUIRED, 2.2: REQUIRED, 2.3: DONE

ruby_2_3 r56783 merged revision(s) 56520.

Actions #5

Updated by usa (Usaku NAKAMURA) about 8 years ago

  • Related to Bug #12920: Strange NoMethodError in Time.now added
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0