ruby-changes:14644
From: yugui <ko1@a...>
Date: Sat, 30 Jan 2010 21:49:25 +0900 (JST)
Subject: [ruby-changes:14644] Ruby:r26490 (ruby_1_9_1): merges r25377 from trunk into ruby_1_9_1.
yugui 2010-01-30 21:49:10 +0900 (Sat, 30 Jan 2010) New Revision: 26490 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26490 Log: merges r25377 from trunk into ruby_1_9_1. -- * st.c (unpack_entries): save table->bins and never change the table during unpacking. Because st_insert() may cause GC and refer the table, i.e. st_foreach(). [Bug #2196] Modified files: branches/ruby_1_9_1/ChangeLog branches/ruby_1_9_1/st.c branches/ruby_1_9_1/version.h Index: ruby_1_9_1/ChangeLog =================================================================== --- ruby_1_9_1/ChangeLog (revision 26489) +++ ruby_1_9_1/ChangeLog (revision 26490) @@ -1,3 +1,9 @@ +Fri Oct 17 00:05:53 2009 wanabe <s.wanabe@g...> + + * st.c (unpack_entries): save table->bins and never change the table + during unpacking. Because st_insert() may cause GC and refer the + table, i.e. st_foreach(). [Bug #2196] + Fri Oct 16 18:42:18 2009 Nobuyoshi Nakada <nobu@r...> * bootstraptest/test_gc.rb: added tests based on [ruby-dev:39484] Index: ruby_1_9_1/st.c =================================================================== --- ruby_1_9_1/st.c (revision 26489) +++ ruby_1_9_1/st.c (revision 26490) @@ -367,15 +367,17 @@ { int i; struct st_table_entry *packed_bins[MAX_PACKED_NUMHASH*2]; - int num_entries = table->num_entries; + st_table tmp_table = *table; - memcpy(packed_bins, table->bins, sizeof(struct st_table_entry *) * num_entries*2); - table->entries_packed = 0; - table->num_entries = 0; - memset(table->bins, 0, sizeof(struct st_table_entry *) * table->num_bins); - for (i = 0; i < num_entries; i++) { - st_insert(table, (st_data_t)packed_bins[i*2], (st_data_t)packed_bins[i*2+1]); + memcpy(packed_bins, table->bins, sizeof(struct st_table_entry *) * table->num_entries*2); + table->bins = packed_bins; + tmp_table.entries_packed = 0; + tmp_table.num_entries = 0; + memset(tmp_table.bins, 0, sizeof(struct st_table_entry *) * tmp_table.num_bins); + for (i = 0; i < table->num_entries; i++) { + st_insert(&tmp_table, (st_data_t)packed_bins[i*2], (st_data_t)packed_bins[i*2+1]); } + *table = tmp_table; } int Index: ruby_1_9_1/version.h =================================================================== --- ruby_1_9_1/version.h (revision 26489) +++ ruby_1_9_1/version.h (revision 26490) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.1" -#define RUBY_PATCHLEVEL 395 +#define RUBY_PATCHLEVEL 396 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/