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

ruby-changes:34638

From: nagachika <ko1@a...>
Date: Sun, 6 Jul 2014 23:32:00 +0900 (JST)
Subject: [ruby-changes:34638] nagachika:r46721 (ruby_2_1): merge revision(s) r45642, r45643: [Backport #9646] [Backport #9729]

nagachika	2014-07-06 23:28:18 +0900 (Sun, 06 Jul 2014)

  New Revision: 46721

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

  Log:
    merge revision(s) r45642,r45643: [Backport #9646] [Backport #9729]
    
    * st.c (st_foreach_check): chnage start point of search at check
      from top to current. [ruby-dev:48047] [Bug #9646]
    
    * st.c (st_foreach_check): change start point of search at check

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/st.c
    branches/ruby_2_1/test/ruby/test_hash.rb
    branches/ruby_2_1/version.h
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 46720)
+++ ruby_2_1/ChangeLog	(revision 46721)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Sun Jul  6 23:16:30 2014  Masaya Tarui  <tarui@r...>
+
+	* st.c (st_foreach_check): change start point of search at check
+	  from top to current. [ruby-dev:48047] [Bug #9646]
+
 Sun Jul  6 22:56:03 2014  Zachary Scott  <e@z...>
 
 	* lib/gserver.rb: [DOC] Fixed typo in example by @stomar [Bug #9543]
Index: ruby_2_1/st.c
===================================================================
--- ruby_2_1/st.c	(revision 46720)
+++ ruby_2_1/st.c	(revision 46721)
@@ -393,9 +393,8 @@ find_entry(st_table *table, st_data_t ke https://github.com/ruby/ruby/blob/trunk/ruby_2_1/st.c#L393
 }
 
 static inline st_index_t
-find_packed_index(st_table *table, st_index_t hash_val, st_data_t key)
+find_packed_index_from(st_table *table, st_index_t hash_val, st_data_t key, st_index_t i)
 {
-    st_index_t i = 0;
     while (i < table->real_entries &&
 	   (PHASH(table, i) != hash_val || !EQUAL(table, key, PKEY(table, i)))) {
 	i++;
@@ -403,6 +402,12 @@ find_packed_index(st_table *table, st_in https://github.com/ruby/ruby/blob/trunk/ruby_2_1/st.c#L402
     return i;
 }
 
+static inline st_index_t
+find_packed_index(st_table *table, st_index_t hash_val, st_data_t key)
+{
+    return find_packed_index_from(table, hash_val, key, 0);
+}
+
 #define collision_check 0
 
 int
@@ -962,9 +967,10 @@ st_foreach_check(st_table *table, int (* https://github.com/ruby/ruby/blob/trunk/ruby_2_1/st.c#L967
 		if (PHASH(table, i) == 0 && PKEY(table, i) == never) {
 		    break;
 		}
-		i = find_packed_index(table, hash, key);
-		if (i == table->real_entries) {
-		    goto deleted;
+		i = find_packed_index_from(table, hash, key, i);
+		if (i >= table->real_entries) {
+		    i = find_packed_index(table, hash, key);
+		    if (i >= table->real_entries) goto deleted;
 		}
 		/* fall through */
 	      case ST_CONTINUE:
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 46720)
+++ ruby_2_1/version.h	(revision 46721)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.2"
 #define RUBY_RELEASE_DATE "2014-07-06"
-#define RUBY_PATCHLEVEL 167
+#define RUBY_PATCHLEVEL 168
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 7
Index: ruby_2_1/test/ruby/test_hash.rb
===================================================================
--- ruby_2_1/test/ruby/test_hash.rb	(revision 46720)
+++ ruby_2_1/test/ruby/test_hash.rb	(revision 46721)
@@ -1087,6 +1087,17 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_hash.rb#L1087
     assert_predicate(h.dup, :compare_by_identity?, bug8703)
   end
 
+  def test_same_key
+    bug9646 = '[ruby-dev:48047] [Bug #9646] Infinite loop at Hash#each'
+    h = @cls[a=[], 1]
+    a << 1
+    h[[]] = 2
+    a.clear
+    cnt = 0
+    r = h.each{ break nil if (cnt+=1) > 100 }
+    assert_not_nil(r,bug9646)
+  end
+
   class ObjWithHash
     def initialize(value, hash)
       @value = value

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r45642-45643


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

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