summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-05 13:46:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-05 13:46:11 +0000
commit31e6f72c8ea0990ca7acdfc7b99b89abd4566f0b (patch)
tree65e21bfa74be32ea9811a108516308316b5dbc65 /vm.c
parent1bddcc72f6e6f7cd5708d9ae34aa3b4a6bbde6c1 (diff)
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
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/vm.c b/vm.c
index d39fe02..b59044d 100644
--- a/vm.c
+++ b/vm.c
@@ -477,10 +477,18 @@ 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 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
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 *lep = VM_CF_LEP(cfp);
rb_block_t *blockptr = VM_EP_BLOCK_PTR(lep);
@@ -490,6 +498,7 @@ rb_vm_make_env_object(rb_thread_t * th, rb_control_frame_t *cfp)
rb_proc_t *p;
GetProcPtr(blockprocval, p);
lep[0] = VM_ENVVAL_BLOCK_PTR(&p->block);
+ *blockprocptr = blockprocval;
}
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.");
}
- envval = rb_vm_make_env_object(th, cfp);
+ envval = vm_make_env_object(th, cfp, &blockprocval);
if (PROCDEBUG) {
check_env_value(envval);