8000 merge revision(s) 51037: [Backport #11277] · github/ruby@7766666 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7766666

Browse files
committed
merge revision(s) 51037: [Backport ruby#11277]
* transcode.c (load_transcoder_entry): fix transcoder loading race condition, by waiting in require. [ruby-dev:49106] [Bug ruby#11277] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@51598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent b2bb029 commit 7766666

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Mon Aug 17 16:22:28 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
2+
3+
* transcode.c (load_transcoder_entry): fix transcoder loading race
4+
condition, by waiting in require. [ruby-dev:49106] [Bug #11277]
5+
16
Mon Aug 17 16:18:13 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
27

38
* array.c (ary_ensure_room_for_push): check if array size will

test/ruby/test_transcode.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,4 +2091,22 @@ def test_valid_dummy_encoding
20912091
assert_equal("\x00\x00\xFE\xFF\x00\x00\x00t\x00\x00\x00e\x00\x00\x00s\x00\x00\x00t", result.b, bug)
20922092
end;
20932093
end
2094+
2095+
def test_loading_race
2096+
assert_separately([], <<-'end;') #do
2097+
bug11277 = '[ruby-dev:49106] [Bug #11277]'
2098+
num = 2
2099+
th = (0...num).map do |i|
2100+
Thread.new {"\u3042".encode("EUC-JP")}
2101+
end
2102+
result = nil
2103+
assert_warning("", bug11277) do
2104+
assert_nothing_raised(Encoding::ConverterNotFoundError, bug11277) do
2105+
result = th.map(&:value)
2106+
end
2107+
end
2108+
expected = "\xa4\xa2".force_encoding(Encoding::EUC_JP)
2109+
assert_equal([expected]*num, result, bug11277)
2110+
end;
2111+
end
20942112
end

transcode.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,15 +372,12 @@ load_transcoder_entry(transcoder_entry_t *entry)
372372
char *const path = RSTRING_PTR(fn);
373373
const int safe = rb_safe_level();
374374

375-
entry->lib = NULL;
376-
377375
memcpy(path, transcoder_lib_prefix, sizeof(transcoder_lib_prefix) - 1);
378376
memcpy(path + sizeof(transcoder_lib_prefix) - 1, lib, len);
379377
rb_str_set_len(fn, total_len);
380378
FL_UNSET(fn, FL_TAINT);
381379
OBJ_FREEZE(fn);
382-
if (!rb_require_safe(fn, safe > 3 ? 3 : safe))
383-
return NULL;
380+
rb_require_safe(fn, safe > 3 ? 3 : safe);
384381
}
385382

386383
if (entry->transcoder)

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.7"
22
#define RUBY_RELEASE_DATE "2015-08-17"
3-
#define RUBY_PATCHLEVEL 381
3+
#define RUBY_PATCHLEVEL 382
44

55
#define RUBY_RELEASE_YEAR 2015
66
#define RUBY_RELEASE_MONTH 8

0 commit comments

Comments
 (0)
0