summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-25 14:29:28 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-25 14:29:28 +0000
commit9a27239558d384b197c650e5d12be1d12c33631f (patch)
tree57ace245e6d76680ca5ac4959dea6eab75b2bbb4 /vm_method.c
parentf23ad92a959ba0a09a9c5c4d4ebbd4aef4b676fe (diff)
* proc.c (struct METHOD), gc.c (gc_marks), vm_method.c
(rb_gc_mark_unlinked_live_method_entries): fix SEGV bug. rb_method_entry_t was free'd even when the method is still on the stack if it is BMETHOD (i.e., Method#call). This is because rb_method_entry_t is embedded in struct METHOD. This commit separates them and marks the live method entries. See [ruby-core:38449] in detail. fix [Bug #5047] [ruby-core:38171] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/vm_method.c b/vm_method.c
index cea26cdc31..6e209f257f 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -86,7 +86,7 @@ rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_me
}
}
-static void
+void
rb_unlink_method_entry(rb_method_entry_t *me)
{
struct unlinked_method_entry_list_entry *ume = ALLOC(struct unlinked_method_entry_list_entry);
@@ -96,6 +96,20 @@ rb_unlink_method_entry(rb_method_entry_t *me)
}
void
+rb_gc_mark_unlinked_live_method_entries(void *pvm)
+{
+ rb_vm_t *vm = pvm;
+ struct unlinked_method_entry_list_entry *ume = vm->unlinked_method_entry_list, *prev_ume = 0, *curr_ume;
+
+ while (ume) {
+ if (ume->me->mark) {
+ rb_mark_method_entry(ume->me);
+ }
+ ume = ume->next;
+ }
+}
+
+void
rb_sweep_method_entry(void *pvm)
{
rb_vm_t *vm = pvm;