diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-09-07 22:33:14 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-09-07 22:33:14 +0000 |
commit | 4fe51cb33042375a11356900d8e618ce3b15cc3f (patch) | |
tree | a4a759e236257f4a48857d58037c104d739f551c /gc.c | |
parent | e3532c8bde441bb6a0430188d9e36f69515bd086 (diff) |
* gc.c (id2ref): unmarked object is already dead while lazy
sweeping, and to it cannot come back since other objects
referred from it might have been freed already.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -390,6 +390,8 @@ int *ruby_initial_gc_stress_ptr = &rb_objspace.gc_stress; #define global_List objspace->global_list #define ruby_gc_stress objspace->gc_stress +#define is_lazy_sweeping(objspace) ((objspace)->heap.sweep_slots != 0) + static void rb_objspace_call_finalizer(rb_objspace_t *objspace); #if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE @@ -3130,7 +3132,8 @@ id2ref(VALUE obj, VALUE objid) BUILTIN_TYPE(ptr) > T_FIXNUM || BUILTIN_TYPE(ptr) == T_ICLASS) { rb_raise(rb_eRangeError, "%p is not id value", p0); } - if (BUILTIN_TYPE(ptr) == 0 || RBASIC(ptr)->klass == 0) { + if (BUILTIN_TYPE(ptr) == 0 || RBASIC(ptr)->klass == 0 || + (is_lazy_sweeping(objspace) && !(RBASIC(ptr)->flags & FL_MARK))) { rb_raise(rb_eRangeError, "%p is recycled object", p0); } return (VALUE)ptr; |