ruby-changes:39393
From: nagachika <ko1@a...>
Date: Tue, 4 Aug 2015 03:57:48 +0900 (JST)
Subject: [ruby-changes:39393] nagachika:r51474 (ruby_2_2): merge revision(s) 51037: [Backport #11277]
nagachika 2015-08-04 03:57:41 +0900 (Tue, 04 Aug 2015) New Revision: 51474 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51474 Log: merge revision(s) 51037: [Backport #11277] * transcode.c (load_transcoder_entry): fix transcoder loading race condition, by waiting in require. [ruby-dev:49106] [Bug #11277] Modified directories: branches/ruby_2_2/ Modified files: branches/ruby_2_2/ChangeLog branches/ruby_2_2/test/ruby/test_transcode.rb branches/ruby_2_2/transcode.c branches/ruby_2_2/version.h Index: ruby_2_2/ChangeLog =================================================================== --- ruby_2_2/ChangeLog (revision 51473) +++ ruby_2_2/ChangeLog (revision 51474) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1 +Tue Aug 4 03:43:15 2015 Nobuyoshi Nakada <nobu@r...> + + * transcode.c (load_transcoder_entry): fix transcoder loading race + condition, by waiting in require. [ruby-dev:49106] [Bug #11277] + Tue Aug 4 03:13:59 2015 Nobuyoshi Nakada <nobu@r...> * array.c (ary_ensure_room_for_push): check if array size will Index: ruby_2_2/version.h =================================================================== --- ruby_2_2/version.h (revision 51473) +++ ruby_2_2/version.h (revision 51474) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1 #define RUBY_VERSION "2.2.3" #define RUBY_RELEASE_DATE "2015-08-04" -#define RUBY_PATCHLEVEL 148 +#define RUBY_PATCHLEVEL 149 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 8 Index: ruby_2_2/test/ruby/test_transcode.rb =================================================================== --- ruby_2_2/test/ruby/test_transcode.rb (revision 51473) +++ ruby_2_2/test/ruby/test_transcode.rb (revision 51474) @@ -2091,4 +2091,22 @@ class TestTranscode < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_transcode.rb#L2091 assert_equal("\x00\x00\xFE\xFF\x00\x00\x00t\x00\x00\x00e\x00\x00\x00s\x00\x00\x00t", result.b, bug) end; end + + def test_loading_race + assert_separately([], <<-'end;') #do + bug11277 = '[ruby-dev:49106] [Bug #11277]' + num = 2 + th = (0...num).map do |i| + Thread.new {"\u3042".encode("EUC-JP")} + end + result = nil + assert_warning("", bug11277) do + assert_nothing_raised(Encoding::ConverterNotFoundError, bug11277) do + result = th.map(&:value) + end + end + expected = "\xa4\xa2".force_encoding(Encoding::EUC_JP) + assert_equal([expected]*num, result, bug11277) + end; + end end Index: ruby_2_2/transcode.c =================================================================== --- ruby_2_2/transcode.c (revision 51473) +++ ruby_2_2/transcode.c (revision 51474) @@ -370,15 +370,12 @@ load_transcoder_entry(transcoder_entry_t https://github.com/ruby/ruby/blob/trunk/ruby_2_2/transcode.c#L370 char *const path = RSTRING_PTR(fn); const int safe = rb_safe_level(); - entry->lib = NULL; - memcpy(path, transcoder_lib_prefix, sizeof(transcoder_lib_prefix) - 1); memcpy(path + sizeof(transcoder_lib_prefix) - 1, lib, len); rb_str_set_len(fn, total_len); FL_UNSET(fn, FL_TAINT); OBJ_FREEZE(fn); - if (!rb_require_safe(fn, safe > 3 ? 3 : safe)) - return NULL; + rb_require_safe(fn, safe > 3 ? 3 : safe); } if (entry->transcoder) Property changes on: ruby_2_2 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r51037 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/