Project

General

Profile

Actions

Bug #1150

closed

calling instance_eval in extended library cause exception

Added by arton (Akio Tajima) about 15 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-mswin32]
Backport:
[ruby-dev:37979]

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

Also available in: Atom PDF

Like0
Like0Like0