diff options
| author | NARUSE, Yui <naruse@airemix.jp> | 2023-03-02 09:28:58 +0900 |
|---|---|---|
| committer | NARUSE, Yui <naruse@airemix.jp> | 2023-03-02 09:29:38 +0900 |
| commit | 53f6173cfc085a7422b4a76c85e6c35969209327 (patch) | |
| tree | 64ffea351625f7655e038fdaad39c4c937adc699 /spec/ruby | |
| parent | 65ab2c1ef23bd4a02120a27c371dce12ea9024d4 (diff) | |
merge revision(s) 8ce2fb9bbbaea14737c84385b1573f743a30f773,3a0f6ce1d31eefd8af01b50f3632a64d64e8f8c1: [Backport #19415]
Only emit circular dependency warning for owned thread shields [Bug
#19415]
If multiple threads attemps to load the same file concurrently
it's not a circular dependency issue.
So we check that the existing ThreadShield is owner by the current
fiber before warning about circular dependencies.
---
internal/thread.h | 1 +
load.c | 3 ++-
spec/ruby/core/kernel/shared/require.rb | 11 +++++++++++
spec/ruby/fixtures/code/concurrent_require_fixture.rb | 4 ++++
test/ruby/test_require.rb | 3 ---
thread.c | 11 +++++++++++
6 files changed, 29 insertions(+), 4 deletions(-)
create mode 100644 spec/ruby/fixtures/code/concurrent_require_fixture.rb
Use Thread.pass until thread.stop? to wait for thread to block
[Bug #19415]
It should be more reliable
---
spec/ruby/fixtures/code/concurrent_require_fixture.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Diffstat (limited to 'spec/ruby')
| -rw-r--r-- | spec/ruby/core/kernel/shared/require.rb | 11 | ||||
| -rw-r--r-- | spec/ruby/fixtures/code/concurrent_require_fixture.rb | 4 |
2 files changed, 15 insertions, 0 deletions
diff --git a/spec/ruby/core/kernel/shared/require.rb b/spec/ruby/core/kernel/shared/require.rb index 666ca15e11..ae814aa317 100644 --- a/spec/ruby/core/kernel/shared/require.rb +++ b/spec/ruby/core/kernel/shared/require.rb @@ -237,6 +237,17 @@ describe :kernel_require, shared: true do }.should complain(/circular require considered harmful/, verbose: true) ScratchPad.recorded.should == [:loaded] end + + ruby_bug "#17340", ''...'3.3' do + it "loads a file concurrently" do + path = File.expand_path "concurrent_require_fixture.rb", CODE_LOADING_DIR + ScratchPad.record(@object) + -> { + @object.require(path) + }.should_not complain(/circular require considered harmful/, verbose: true) + ScratchPad.recorded.join + end + end end describe "(non-extensioned path)" do diff --git a/spec/ruby/fixtures/code/concurrent_require_fixture.rb b/spec/ruby/fixtures/code/concurrent_require_fixture.rb new file mode 100644 index 0000000000..d4ce734183 --- /dev/null +++ b/spec/ruby/fixtures/code/concurrent_require_fixture.rb @@ -0,0 +1,4 @@ +object = ScratchPad.recorded +thread = Thread.new { object.require(__FILE__) } +Thread.pass until thread.stop? +ScratchPad.record(thread) |
