aboutsummaryrefslogtreecommitdiffstats
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
parente3532c8bde441bb6a0430188d9e36f69515bd086 (diff)
downloadruby-4fe51cb33042375a11356900d8e618ce3b15cc3f.tar.gz
* 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
-rw-r--r--ChangeLog6
-rw-r--r--gc.c5
2 files changed, 10 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index ff648d1a66..8e96ed81b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Thu Sep 8 07:33:12 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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.
+
Wed Sep 8 03:48:00 2011 Ayumu AIZAWA <ayumu.aizawa@gmail.com>
* ext/readline/README.ja:
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;