[前][次][番号順一覧][スレッド一覧]

ruby-changes:32162

From: ko1 <ko1@a...>
Date: Mon, 16 Dec 2013 19:16:57 +0900 (JST)
Subject: [ruby-changes:32162] ko1:r44241 (trunk): * ext/objspace/objspace.c (reachable_object_from_root_i): use

ko1	2013-12-16 19:16:51 +0900 (Mon, 16 Dec 2013)

  New Revision: 44241

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44241

  Log:
    * ext/objspace/objspace.c (reachable_object_from_root_i): use
      compare_by_identity hash to avoid hash modify problem
      during iteration.
      [Bug #9252]
    * ext/objspace/objspace.c (reachable_objects_from_root): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/ext/objspace/objspace.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 44240)
+++ ChangeLog	(revision 44241)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Dec 16 19:12:54 2013  Koichi Sasada  <ko1@a...>
+
+	* ext/objspace/objspace.c (reachable_object_from_root_i): use
+	  compare_by_identity hash to avoid hash modify problem
+	  during iteration.
+	  [Bug #9252]
+
+	* ext/objspace/objspace.c (reachable_objects_from_root): ditto.
+
 Mon Dec 16 18:16:28 2013  Koichi Sasada  <ko1@a...>
 
 	* gc.c (gc_verify_internal_consistency): should not use
Index: ext/objspace/objspace.c
===================================================================
--- ext/objspace/objspace.c	(revision 44240)
+++ ext/objspace/objspace.c	(revision 44241)
@@ -673,6 +673,7 @@ reachable_object_from_root_i(const char https://github.com/ruby/ruby/blob/trunk/ext/objspace/objspace.c#L673
 	data->last_category = category;
 	category_str = data->last_category_str = rb_str_new2(category);
 	category_objects = data->last_category_objects = rb_hash_new();
+	rb_funcall(category_objects, rb_intern("compare_by_identity"), 0);
 	if (!NIL_P(rb_hash_lookup(data->categories, category_str))) {
 	    rb_bug("reachable_object_from_root_i: category should insert at once");
 	}
@@ -711,6 +712,7 @@ reachable_objects_from_root(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/objspace/objspace.c#L712
     VALUE hash = data.categories = rb_hash_new();
     data.last_category = 0;
 
+    rb_funcall(hash, rb_intern("compare_by_identity"), 0);
     rb_objspace_reachable_objects_from_root(reachable_object_from_root_i, &data);
     rb_hash_foreach(hash, collect_values_of_values, hash);
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]