зеркало из https://github.com/github/ruby.git
vm.c: rewrite all catch points
* vm.c (rb_vm_rewrite_ep_in_errinfo): rewrite all catch points in errinfo, not only the topmost frame. based on the patch by ktsj (Kazuki Tsujimoto) in [ruby-dev:45656]. [Bug #6460] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
0446be770e
Коммит
f7894e422a
|
@ -1,3 +1,9 @@
|
|||
Sat Nov 3 04:14:19 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* vm.c (rb_vm_rewrite_ep_in_errinfo): rewrite all catch points in
|
||||
errinfo, not only the topmost frame. based on the patch by
|
||||
ktsj (Kazuki Tsujimoto) in [ruby-dev:45656]. [Bug #6460]
|
||||
|
||||
Fri Nov 2 20:11:17 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/mkmf.rb (MakeMakefile#timestamp_file): remove @ which looks like
|
||||
|
|
18
KNOWNBUGS.rb
18
KNOWNBUGS.rb
|
@ -3,21 +3,3 @@
|
|||
# So all tests will cause failure.
|
||||
#
|
||||
|
||||
[['[ruby-dev:45656]', %q{
|
||||
class Bug6460
|
||||
include Enumerable
|
||||
def each
|
||||
begin
|
||||
yield :foo
|
||||
ensure
|
||||
1.times { Proc.new }
|
||||
end
|
||||
end
|
||||
end
|
||||
e = Bug6460.new
|
||||
}]].each do |bug, src|
|
||||
assert_equal "foo", src + %q{e.detect {true}}, bug
|
||||
assert_equal "true", src + %q{e.any? {true}}, bug
|
||||
assert_equal "false", src + %q{e.all? {false}}, bug
|
||||
assert_equal "true", src + %q{e.include?(:foo)}, bug
|
||||
end
|
||||
|
|
|
@ -543,9 +543,49 @@ assert_equal %Q{ENSURE\n}, %q{
|
|||
end
|
||||
end
|
||||
e = Bug5234.new
|
||||
}],
|
||||
['[ruby-dev:45656]', %q{
|
||||
class Bug6460
|
||||
include Enumerable
|
||||
def each
|
||||
begin
|
||||
yield :foo
|
||||
ensure
|
||||
1.times { Proc.new }
|
||||
end
|
||||
end
|
||||
end
|
||||
e = Bug6460.new
|
||||
}]].each do |bug, src|
|
||||
assert_equal "foo", src + %q{e.detect {true}}, bug
|
||||
assert_equal "true", src + %q{e.any? {true}}, bug
|
||||
assert_equal "false", src + %q{e.all? {false}}, bug
|
||||
assert_equal "true", src + %q{e.include?(:foo)}, bug
|
||||
end
|
||||
|
||||
assert_equal "foo", %q{
|
||||
class Bug6460
|
||||
def m1
|
||||
m2 {|e|
|
||||
return e
|
||||
}
|
||||
end
|
||||
|
||||
def m2
|
||||
begin
|
||||
yield :foo
|
||||
ensure
|
||||
begin
|
||||
begin
|
||||
yield :foo
|
||||
ensure
|
||||
Proc.new
|
||||
raise ''
|
||||
end
|
||||
rescue
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Bug6460.new.m1
|
||||
}, '[ruby-dev:46372]'
|
||||
|
|
16
vm.c
16
vm.c
|
@ -434,7 +434,8 @@ vm_make_env_each(rb_thread_t * const th, rb_control_frame_t * const cfp,
|
|||
if (!RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) {
|
||||
/* TODO */
|
||||
env->block.iseq = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
rb_vm_rewrite_ep_in_errinfo(th, cfp);
|
||||
}
|
||||
return envval;
|
||||
|
@ -493,8 +494,19 @@ rb_vm_make_env_object(rb_thread_t * th, rb_control_frame_t *cfp)
|
|||
return envval;
|
||||
}
|
||||
|
||||
static void vm_rewrite_ep_in_errinfo(rb_thread_t *th, rb_control_frame_t *cfp);
|
||||
|
||||
void
|
||||
rb_vm_rewrite_ep_in_errinfo(rb_thread_t *th, rb_control_frame_t *cfp)
|
||||
{
|
||||
while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)) {
|
||||
vm_rewrite_ep_in_errinfo(th, cfp);
|
||||
cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
vm_rewrite_ep_in_errinfo(rb_thread_t *th, rb_control_frame_t *cfp)
|
||||
{
|
||||
/* rewrite ep in errinfo to point to heap */
|
||||
if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq) &&
|
||||
|
@ -505,7 +517,7 @@ rb_vm_rewrite_ep_in_errinfo(rb_thread_t *th, rb_control_frame_t *cfp)
|
|||
VALUE *escape_ep = GET_THROWOBJ_CATCH_POINT(errinfo);
|
||||
if (! ENV_IN_HEAP_P(th, escape_ep)) {
|
||||
VALUE epval = *escape_ep;
|
||||
if (CLASS_OF(epval) == rb_cEnv) {
|
||||
if (!SPECIAL_CONST_P(epval) && RBASIC(epval)->klass == rb_cEnv) {
|
||||
rb_env_t *epenv;
|
||||
GetEnvPtr(epval, epenv);
|
||||
SET_THROWOBJ_CATCH_POINT(errinfo, (VALUE)(epenv->env + epenv->local_size));
|
||||
|
|
Загрузка…
Ссылка в новой задаче