diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2022-05-17 19:12:36 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-17 19:12:36 +1200 |
commit | 60d45b2ee86a80e248c3bff0c90c981ed2168ac3 (patch) | |
tree | 55a3796c04d86fb16da9d08cf6b00774e8b9a4a3 /test/ruby/test_autoload.rb | |
parent | 8a907da0f69d66aaedad8518e69cd1160b693840 (diff) |
Restore implicit relationship between `autoload_const` and `autoload_data` during GC. (#5911)
Notes
Notes:
Merged-By: ioquatix <samuel@codeotaku.com>
Diffstat (limited to 'test/ruby/test_autoload.rb')
-rw-r--r-- | test/ruby/test_autoload.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb index afabd5d26b..f6183f5ee2 100644 --- a/test/ruby/test_autoload.rb +++ b/test/ruby/test_autoload.rb @@ -492,6 +492,26 @@ p Foo::Bar TestAutoload.class_eval {remove_const(:AutoloadTest)} if defined? TestAutoload::AutoloadTest end + def test_autoload_module_gc + Dir.mktmpdir('autoload') do |tmpdir| + autoload_path = File.join(tmpdir, "autoload_module_gc.rb") + File.write(autoload_path, "X = 1; Y = 2;") + + x = Module.new + x.autoload :X, "./feature.rb" + + 1000.times do + y = Module.new + y.autoload :Y, "./feature.rb" + end + + x = y = nil + + # Ensure the internal data structures are cleaned up correctly / don't crash: + GC.start + end + end + def test_autoload_parallel_race Dir.mktmpdir('autoload') do |tmpdir| autoload_path = File.join(tmpdir, "autoload_parallel_race.rb") |