[#62297] Re: [ruby-cvs:52906] nari:r45760 (trunk): * gc.c (gc_after_sweep): suppress unnecessary expanding heap. — Eric Wong <normalperson@...>
nari@ruby-lang.org wrote:
7 messages
2014/05/02
[#62307] Re: [ruby-cvs:52906] nari:r45760 (trunk): * gc.c (gc_after_sweep): suppress unnecessary expanding heap.
— SASADA Koichi <ko1@...>
2014/05/03
(2014/05/03 4:41), Eric Wong wrote:
[#62402] Re: [ruby-cvs:52906] nari:r45760 (trunk): * gc.c (gc_after_sweep): suppress unnecessary expanding heap.
— Eric Wong <normalperson@...>
2014/05/05
SASADA Koichi <ko1@atdot.net> wrote:
[#62523] [ruby-trunk - Feature #9632] [PATCH 0/2] speedup IO#close with linked-list from ccan — ko1@...
Issue #9632 has been updated by Koichi Sasada.
3 messages
2014/05/11
[#62556] doxygen (Re: Re: [ruby-trunk - Feature #9632] [PATCH 0/2] speedup IO#close with linked-list from ccan) — Tanaka Akira <akr@...>
2014-05-11 8:50 GMT+09:00 Eric Wong <normalperson@yhbt.net>:
3 messages
2014/05/13
[#62727] [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl — Eric Wong <normalperson@...>
rb_unlink_method_entry may cause old_me to be swept before the new
7 messages
2014/05/24
[#63039] Re: [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl
— SASADA Koichi <ko1@...>
2014/06/10
Hi,
[#63077] Re: [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl
— Eric Wong <normalperson@...>
2014/06/10
SASADA Koichi <ko1@atdot.net> wrote:
[#63086] Re: [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl
— SASADA Koichi <ko1@...>
2014/06/11
(2014/06/11 4:47), Eric Wong wrote:
[#63087] Re: [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl
— Eric Wong <normalperson@...>
2014/06/11
SASADA Koichi <ko1@atdot.net> wrote:
[#62862] [RFC] README.EXT: document rb_gc_register_mark_object — Eric Wong <normalperson@...>
Any comment on officially supporting this as part of the C API?
5 messages
2014/05/30
[ruby-core:62727] [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl
From:
Eric Wong <normalperson@...>
Date:
2014-05-24 17:45:17 UTC
List:
ruby-core #62727
rb_unlink_method_entry may cause old_me to be swept before the new
method is inserted; allowing for a window where the method entry may
be prematurely freed/swept but still referenced in the old slot of
the method entry table.
From what I can tell, this is not currently a problem with when using
st. However, with my proposed ihash method table implementation, this
caused a segfault with the test[1] for bug #8100 where the method entry
is itself a linked list node, there is no st_table_entry.
Right now, this patch will make us more robust against future changes.
[1] test/ruby/test_method.rb:
test_unlinked_method_entry_in_method_object_bug
---
Thoughts? I will likely commit this separately since changing the
method table implementation may not happen soon.
vm_method.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/vm_method.c b/vm_method.c
index d551332..beb9008 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -255,6 +255,7 @@ rb_method_entry_make(VALUE klass, ID mid, rb_method_type_t type,
st_table *mtbl;
st_data_t data;
int make_refined = 0;
+ rb_method_entry_t *old_me;
if (NIL_P(klass)) {
klass = rb_cObject;
@@ -279,8 +280,7 @@ rb_method_entry_make(VALUE klass, ID mid, rb_method_type_t type,
rb_add_refined_method_entry(refined_class, mid);
}
if (type == VM_METHOD_TYPE_REFINED) {
- rb_method_entry_t *old_me =
- lookup_method_table(RCLASS_ORIGIN(klass), mid);
+ old_me = lookup_method_table(RCLASS_ORIGIN(klass), mid);
if (old_me) rb_vm_check_redefinition_opt_method(old_me, klass);
}
else {
@@ -289,9 +289,12 @@ rb_method_entry_make(VALUE klass, ID mid, rb_method_type_t type,
mtbl = RCLASS_M_TBL(klass);
/* check re-definition */
+ old_me = 0;
if (st_lookup(mtbl, mid, &data)) {
- rb_method_entry_t *old_me = (rb_method_entry_t *)data;
- rb_method_definition_t *old_def = old_me->def;
+ rb_method_definition_t *old_def;
+
+ old_me = (rb_method_entry_t *)data;
+ old_def = old_me->def;
if (rb_method_definition_eq(old_def, def)) return old_me;
#if NOEX_NOREDEF
@@ -329,8 +332,6 @@ rb_method_entry_make(VALUE klass, ID mid, rb_method_type_t type,
rb_id2name(old_def->original_id));
}
}
-
- rb_unlink_method_entry(old_me);
}
mid = SYM2ID(ID2SYM(mid));
@@ -379,6 +380,9 @@ rb_method_entry_make(VALUE klass, ID mid, rb_method_type_t type,
}
st_insert(mtbl, mid, (st_data_t) me);
+ if (old_me) {
+ rb_unlink_method_entry(old_me);
+ }
return me;
}
--
Eric Wong