summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-07 22:33:14 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-07 22:33:14 +0000
commit4fe51cb33042375a11356900d8e618ce3b15cc3f (patch)
treea4a759e236257f4a48857d58037c104d739f551c /gc.c
parente3532c8bde441bb6a0430188d9e36f69515bd086 (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.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/gc.c b/gc.c
index e6784624a4..e2e3625635 100644
--- a/gc.c
+++ b/gc.c
@@ -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;