Actions
Bug #1150
closedcalling instance_eval in extended library cause exception
Description
=begin
拡張ライブラリ内のメソッドでinstance_evalを呼び出すと、Can't eval on top of Fiber or Thread (RuntimeError)になります。
再現コードを以下に示します。
// cmodev.c
#include "ruby.h"
#include "extconf.h"
static VALUE cmodev;
static VALUE xtest_func(VALUE self, VALUE s)
{
return rb_funcall2(self, rb_intern("instance_eval"), 1, &s);
}
void Init_cmodev()
{
cmodev = rb_define_class("XTest", rb_cObject);
rb_define_method(cmodev, "xtest", xtest_func, 1);
}
#t.rb
require 'cmodev'
x = XTest.new
x.xtest("puts 'hello'")
実行例
c:\test\modev\test>ruby t.rb
t.rb:3:in instance_eval': Can't eval on top of Fiber or Thread (RuntimeError) from t.rb:3:in
xtest'
from t.rb:3:in `'
=end
Actions
Like0
Like0Like0