Project

General

Profile

Actions

Bug #3786

closed

instance_execにメソッドをわたした場合の挙動

Added by at_akada (Takada Atsushi) about 14 years ago. Updated over 13 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]
Backport:
[:]

Description

=begin
はじめまして。Ruby1.9.2のバグらしきものを発見したので報告します。
以下のコードを実行すると、エラーで落ちます。

バージョンは以下。ちなみに1.9.1では再現しませんでした。
$ /usr/klab/app/ruby-1.9.2/bin/ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]

class Cl
def metho
p self
end
end

i = Cl::new
metho = i.method(:metho)
1.upto(30) do
"".instance_exec(&metho)
end

出力は以下の通りです。
bug.rb:10: [BUG] vm_get_cref: unreachable
ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]

-- control frame ----------
c:0007 p:---- s:0019 b:0019 l:000018 d:000018 CFUNC :instance_exec
c:0006 p:0013 s:0016 b:0016 l:0022dc d:000015 BLOCK bug.rb:10
c:0005 p:---- s:0014 b:0014 l:000013 d:000013 FINISH
c:0004 p:---- s:0012 b:0012 l:000011 d:000011 CFUNC :upto
c:0003 p:0056 s:0008 b:0008 l:0022dc d:00093c EVAL bug.rb:9
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0022dc d:0022dc TOP

-- Ruby level backtrace information ----------------------------------------
bug.rb:9:in <main>' bug.rb:9:in upto'
bug.rb:10:in block in <main>' bug.rb:10:in instance_exec'

-- C level backtrace information -------------------------------------------
/usr/app/ruby-1.9.2/bin/ruby(rb_vm_bugreport+0xbd) [0x816d68d]
/usr/app/ruby-1.9.2/bin/ruby [0x81ae41e]
/usr/app/ruby-1.9.2/bin/ruby(rb_bug+0x28) [0x81ae4b8]
/usr/app/ruby-1.9.2/bin/ruby [0x816972c]
/usr/app/ruby-1.9.2/bin/ruby [0x815846d]
/usr/app/ruby-1.9.2/bin/ruby [0x8160542]
/usr/app/ruby-1.9.2/bin/ruby [0x8161c64]
/usr/app/ruby-1.9.2/bin/ruby [0x81672f4]
/usr/app/ruby-1.9.2/bin/ruby(rb_yield+0x4f) [0x8168a6f]
/usr/app/ruby-1.9.2/bin/ruby [0x808f559]
/usr/app/ruby-1.9.2/bin/ruby [0x8160542]
/usr/app/ruby-1.9.2/bin/ruby [0x8161c64]
/usr/app/ruby-1.9.2/bin/ruby [0x81672f4]
/usr/app/ruby-1.9.2/bin/ruby(rb_iseq_eval_main+0x1d3) [0x8167643]
/usr/app/ruby-1.9.2/bin/ruby [0x805e2c2]
/usr/app/ruby-1.9.2/bin/ruby(ruby_run_node+0x32) [0x805fb72]
/usr/app/ruby-1.9.2/bin/ruby(main+0x60) [0x805d580]
/lib/i686/cmov/libc.so.6(__libc_start_main+0xe5) [0xb7d6ab55]
/usr/app/ruby-1.9.2/bin/ruby [0x805d481]
=end


Related issues 3 (0 open3 closed)

Is duplicate of Ruby master - Bug #3860: VM aborts when calling instance_eval on a Method converted to a procClosed09/23/2010Actions
Has duplicate Backport192 - Backport #3868: Segfault in 1.9.2 when using instance_eval with a Method objectClosed09/24/2010Actions
Has duplicate Backport192 - Backport #3957: instance_exec and instance_eval crash ruby when passed '&variable' which stores a 'method(:whatever).to_param'Closed10/17/2010Actions
Actions #1

Updated by naruse (Yui NARUSE) about 14 years ago

  • Category set to YARV
  • Status changed from Open to Assigned
  • Assignee set to ko1 (Koichi Sasada)
  • Target version set to 1.9.2
  • ruby -v set to ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]

=begin
trunk でも再現しますね
=end

Actions #2

Updated by wanabe (_ wanabe) about 14 years ago

=begin
ワナベと申します。

vm_get_cref が C レベルの iseq を想定していないように見えます。
これでどうでしょうか。

diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 985a2fb..063e2bf 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1059,7 +1059,11 @@ vm_get_cref(const rb_iseq_t *iseq, const VALUE *lfp, const VALUE *dfp)
while (1) {
if (lfp == dfp) {

  •       cref = iseq->cref_stack;
    
  •       if (RUBY_VM_NORMAL_ISEQ_P(iseq)) {
    
  •           cref = iseq->cref_stack;
    
  •       } else {
    
  •           cref = NEW_BLOCK(0);
    
  •       }
          break;
      }
      else if (dfp[-1] != Qnil) {
    

=end

Actions #3

Updated by nobu (Nobuyoshi Nakada) about 14 years ago

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

=begin
This issue was solved with changeset r29318.
Takada, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0