зеркало из https://github.com/github/ruby.git
vm.c: save blockprocval
* vm.c (rb_vm_make_proc): save the proc made from the given block so that it will not get collected. [ruby-core:50545] [Bug #7507] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
1bddcc72f6
Коммит
31e6f72c8e
|
@ -1,3 +1,8 @@
|
||||||
|
Wed Dec 5 22:46:02 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* vm.c (rb_vm_make_proc): save the proc made from the given block so
|
||||||
|
that it will not get collected. [ruby-core:50545] [Bug #7507]
|
||||||
|
|
||||||
Wed Dec 5 22:13:57 2012 Naohisa Goto <ngotogenome@gmail.com>
|
Wed Dec 5 22:13:57 2012 Naohisa Goto <ngotogenome@gmail.com>
|
||||||
|
|
||||||
* ext/dl/lib/dl/func.rb (DL::Function#bind): When Fiddle is used,
|
* ext/dl/lib/dl/func.rb (DL::Function#bind): When Fiddle is used,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
require_relative 'envutil'
|
||||||
|
|
||||||
class TestLazyEnumerator < Test::Unit::TestCase
|
class TestLazyEnumerator < Test::Unit::TestCase
|
||||||
class Step
|
class Step
|
||||||
|
@ -356,4 +357,10 @@ EOS
|
||||||
assert_equal nil, lazy.select{}.cycle(4).size
|
assert_equal nil, lazy.select{}.cycle(4).size
|
||||||
assert_equal nil, lazy.select{}.cycle.size
|
assert_equal nil, lazy.select{}.cycle.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_map_zip
|
||||||
|
bug7507 = '[ruby-core:50545]'
|
||||||
|
assert_ruby_status(["-e", "GC.stress = true", "-e", "(1..10).lazy.map{}.zip(){}"], bug7507)
|
||||||
|
assert_ruby_status(["-e", "GC.stress = true", "-e", "(1..10).lazy.map{}.zip().to_a"], bug7507)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
11
vm.c
11
vm.c
|
@ -477,9 +477,17 @@ vm_collect_local_variables_in_heap(rb_thread_t *th, VALUE *ep, VALUE ary)
|
||||||
|
|
||||||
static void vm_rewrite_ep_in_errinfo(rb_thread_t *th);
|
static void vm_rewrite_ep_in_errinfo(rb_thread_t *th);
|
||||||
static VALUE vm_make_proc_from_block(rb_thread_t *th, rb_block_t *block);
|
static VALUE vm_make_proc_from_block(rb_thread_t *th, rb_block_t *block);
|
||||||
|
static VALUE vm_make_env_object(rb_thread_t * th, rb_control_frame_t *cfp, VALUE *blockprocptr);
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_vm_make_env_object(rb_thread_t * th, rb_control_frame_t *cfp)
|
rb_vm_make_env_object(rb_thread_t * th, rb_control_frame_t *cfp)
|
||||||
|
{
|
||||||
|
VALUE blockprocval;
|
||||||
|
return vm_make_env_object(th, cfp, &blockprocval);
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp, VALUE *blockprocptr)
|
||||||
{
|
{
|
||||||
VALUE envval;
|
VALUE envval;
|
||||||
VALUE *lep = VM_CF_LEP(cfp);
|
VALUE *lep = VM_CF_LEP(cfp);
|
||||||
|
@ -490,6 +498,7 @@ rb_vm_make_env_object(rb_thread_t * th, rb_control_frame_t *cfp)
|
||||||
rb_proc_t *p;
|
rb_proc_t *p;
|
||||||
GetProcPtr(blockprocval, p);
|
GetProcPtr(blockprocval, p);
|
||||||
lep[0] = VM_ENVVAL_BLOCK_PTR(&p->block);
|
lep[0] = VM_ENVVAL_BLOCK_PTR(&p->block);
|
||||||
|
*blockprocptr = blockprocval;
|
||||||
}
|
}
|
||||||
|
|
||||||
envval = vm_make_env_each(th, cfp, cfp->ep, lep);
|
envval = vm_make_env_each(th, cfp, cfp->ep, lep);
|
||||||
|
@ -560,7 +569,7 @@ rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass)
|
||||||
rb_bug("rb_vm_make_proc: Proc value is already created.");
|
rb_bug("rb_vm_make_proc: Proc value is already created.");
|
||||||
}
|
}
|
||||||
|
|
||||||
envval = rb_vm_make_env_object(th, cfp);
|
envval = vm_make_env_object(th, cfp, &blockprocval);
|
||||||
|
|
||||||
if (PROCDEBUG) {
|
if (PROCDEBUG) {
|
||||||
check_env_value(envval);
|
check_env_value(envval);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче