aboutsummaryrefslogtreecommitdiffstats
path: root/tool
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2023-11-27 11:30:47 -0500
committerPeter Zhu <peter@peterzhu.ca>2023-11-27 12:40:26 -0500
commit150ed44d87e2d5b00f38019a487e05a67a303482 (patch)
tree4529f79d8f9de20071717bc9c189b43e557ee346 /tool
parent3af56e87ca79740521c81e1336cfb5523f55ee29 (diff)
downloadruby-150ed44d87e2d5b00f38019a487e05a67a303482.tar.gz
Fix compaction during ary_make_partial
The ary_make_shared call may allocate, which can trigger a GC compaction. This can cause the array to be embedded because it has a length of 0.
Diffstat (limited to 'tool')
-rw-r--r--tool/lib/envutil.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/tool/lib/envutil.rb b/tool/lib/envutil.rb
index 1ca76d17a7..e47523a24b 100644
--- a/tool/lib/envutil.rb
+++ b/tool/lib/envutil.rb
@@ -245,6 +245,15 @@ module EnvUtil
end
module_function :under_gc_stress
+ def under_gc_compact_stress(&block)
+ auto_compact = GC.auto_compact
+ GC.auto_compact = true
+ under_gc_stress(&block)
+ ensure
+ GC.auto_compact = auto_compact
+ end
+ module_function :under_gc_compact_stress
+
def with_default_external(enc)
suppress_warning { Encoding.default_external = enc }
yield