diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-09 15:42:52 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-09 15:42:52 +0000 |
commit | b5b1a2131ec5cbde6adaf0d37953ff05c393218b (patch) | |
tree | 9bb7cc204bb2f82b6efd3c0e4a77d034e6103cb5 /test | |
parent | 2d909ca11f2d61171a9afca3ccca7e07db1e4527 (diff) |
merge revision(s) 58587,58588: [Backport #13526]
variable.c: cleanup waitq upon thread death
* variable.c (autoload_reset): use idempotent list_del_init
(autoload_sleep): moved code from rb_autoload_load
(autoload_sleep_done): cleanup for use with rb_ensure
(rb_autoload_load): ensure list delete happens in case the
thread dies during sleep
* test/ruby/bug-13526.rb: new script for separate execution
* test/ruby/test_autoload.rb (test_bug_13526): new test
[ruby-core:81016] [Bug #13526]
* properties.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@58637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/bug-13526.rb | 20 | ||||
-rw-r--r-- | test/ruby/test_autoload.rb | 5 |
2 files changed, 25 insertions, 0 deletions
diff --git a/test/ruby/bug-13526.rb b/test/ruby/bug-13526.rb new file mode 100644 index 0000000000..f42e1913ce --- /dev/null +++ b/test/ruby/bug-13526.rb @@ -0,0 +1,20 @@ +# From https://bugs.ruby-lang.org/issues/13526#note-1 + +sleep if $load +$load = true + +n = 10 +threads = Array.new(n) do + Thread.new do + begin + autoload :Foo, "#{File.dirname($0)}/#{$0}" + Thread.pass + Foo + ensure + Thread.pass + end + end +end + +Thread.pass while threads.all?(&:stop?) +100.times { Thread.pass } diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb index b2d8d660fe..961825e0d0 100644 --- a/test/ruby/test_autoload.rb +++ b/test/ruby/test_autoload.rb @@ -241,6 +241,11 @@ p Foo::Bar end end + def test_bug_13526 + script = File.join(__dir__, 'bug-13526.rb') + assert_ruby_status([script], '', '[ruby-core:81016] [Bug #13526]') + end + def add_autoload(path) (@autoload_paths ||= []) << path ::Object.class_eval {autoload(:AutoloadTest, path)} |