summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-20 05:45:53 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-20 05:45:53 +0000
commit28f249a75bb6d6d15ba3ad558af6a5d9d4c650d0 (patch)
treea9edc99173c7b287b9606f8aea51c95a70f0dff3 /proc.c
parent13d3a280490bee122444b3398b6bd2a489c5ca08 (diff)
merge revision(s) 48000: [Backport #10368]
* vm_core.h, vm.c, proc.c: fix GC mark miss on bindings. [ruby-dev:48616] [Bug #10368] * test/ruby/test_eval.rb: add a test code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@48048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c36
1 files changed, 8 insertions, 28 deletions
diff --git a/proc.c b/proc.c
index 600549c52f..d8f0b28e1a 100644
--- a/proc.c
+++ b/proc.c
@@ -259,6 +259,7 @@ binding_mark(void *ptr)
bind = ptr;
RUBY_MARK_UNLESS_NULL(bind->env);
RUBY_MARK_UNLESS_NULL(bind->path);
+ RUBY_MARK_UNLESS_NULL(bind->blockprocval);
}
RUBY_MARK_LEAVE("binding");
}
@@ -278,8 +279,8 @@ static const rb_data_type_t binding_data_type = {
},
};
-static VALUE
-binding_alloc(VALUE klass)
+VALUE
+rb_binding_alloc(VALUE klass)
{
VALUE obj;
rb_binding_t *bind;
@@ -291,12 +292,13 @@ binding_alloc(VALUE klass)
static VALUE
binding_dup(VALUE self)
{
- VALUE bindval = binding_alloc(rb_cBinding);
+ VALUE bindval = rb_binding_alloc(rb_cBinding);
rb_binding_t *src, *dst;
GetBindingPtr(self, src);
GetBindingPtr(bindval, dst);
dst->env = src->env;
dst->path = src->path;
+ dst->blockprocval = src->blockprocval;
dst->first_lineno = src->first_lineno;
return bindval;
}
@@ -313,30 +315,7 @@ binding_clone(VALUE self)
VALUE
rb_binding_new_with_cfp(rb_thread_t *th, const rb_control_frame_t *src_cfp)
{
- rb_control_frame_t *cfp = rb_vm_get_binding_creatable_next_cfp(th, src_cfp);
- rb_control_frame_t *ruby_level_cfp = rb_vm_get_ruby_level_next_cfp(th, src_cfp);
- VALUE bindval, envval;
- rb_binding_t *bind;
-
- if (cfp == 0 || ruby_level_cfp == 0) {
- rb_raise(rb_eRuntimeError, "Can't create Binding Object on top of Fiber.");
- }
-
- while (1) {
- envval = rb_vm_make_env_object(th, cfp);
- if (cfp == ruby_level_cfp) {
- break;
- }
- cfp = rb_vm_get_binding_creatable_next_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));
- }
-
- bindval = binding_alloc(rb_cBinding);
- GetBindingPtr(bindval, bind);
- bind->env = envval;
- bind->path = ruby_level_cfp->iseq->location.path;
- bind->first_lineno = rb_vm_get_sourceline(ruby_level_cfp);
-
- return bindval;
+ return rb_vm_make_binding(th, src_cfp);
}
VALUE
@@ -2126,9 +2105,10 @@ proc_binding(VALUE self)
}
}
- bindval = binding_alloc(rb_cBinding);
+ bindval = rb_binding_alloc(rb_cBinding);
GetBindingPtr(bindval, bind);
bind->env = proc->envval;
+ bind->blockprocval = proc->blockprocval;
if (RUBY_VM_NORMAL_ISEQ_P(proc->block.iseq)) {
bind->path = proc->block.iseq->location.path;
bind->first_lineno = rb_iseq_first_lineno(proc->block.iseq);