summaryrefslogtreecommitdiff
path: root/test/-ext-
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2021-09-05 12:19:53 +0900
committernagachika <nagachika@ruby-lang.org>2021-09-05 12:19:53 +0900
commit92846db6861eed324288819157e6c7722fc62fc2 (patch)
tree82b3c49b5e66b48734a6794e6b5293a887c4558c /test/-ext-
parent261a0e0e4a3202ca004eddc3cc2cefc9e8d0a90a (diff)
merge revision(s) cd4f5b13228879d954fa97b6aa479c4a5ef4fb0a,8db269edb3550a85dfab9b193ea115ca36912ced,ab63f6d8543903f177c46634f38e5428655f003b: [Backport #18140]
Guard array when appending This prevents early collection of the array. The GC doesn't see the array on the stack when Ruby is compiled with optimizations enabled [ruby-core:105099] [Bug #18140] --- array.c | 1 + test/ruby/test_array.rb | 6 ++++++ 2 files changed, 7 insertions(+) Guard array when appending This prevents early collection of the array. The GC doesn't see the array on the stack when Ruby is compiled with optimizations enabled Thanks @jhaberman for the test case [ruby-core:105099] [Bug #18140] --- ext/-test-/array/concat/depend | 321 ++++++++++++++++++++++++++++++++ ext/-test-/array/concat/extconf.rb | 2 + ext/-test-/array/concat/to_ary_conact.c | 64 +++++++ test/-ext-/array/test_to_ary_concat.rb | 20 ++ 4 files changed, 407 insertions(+) create mode 100644 ext/-test-/array/concat/depend create mode 100644 ext/-test-/array/concat/extconf.rb create mode 100644 ext/-test-/array/concat/to_ary_conact.c create mode 100644 test/-ext-/array/test_to_ary_concat.rb Refined test [Bug #18140] --- ext/-test-/array/concat/to_ary_conact.c | 48 +++++++-------------------------- test/ruby/test_array.rb | 5 +++- 2 files changed, 13 insertions(+), 40 deletions(-)
Diffstat (limited to 'test/-ext-')
-rw-r--r--test/-ext-/array/test_to_ary_concat.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/-ext-/array/test_to_ary_concat.rb b/test/-ext-/array/test_to_ary_concat.rb
new file mode 100644
index 0000000000..feb1bc1109
--- /dev/null
+++ b/test/-ext-/array/test_to_ary_concat.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: false
+require 'test/unit'
+require '-test-/array/to_ary_concat'
+
+class TestConcatStress < Test::Unit::TestCase
+ def setup
+ @stress_level = GC.stress
+ GC.stress = true
+ end
+
+ def teardown
+ GC.stress = @stress_level
+ end
+
+ def test_concat
+ arr = [nil]
+ bar = Bug::Bar.new
+ arr.concat(bar)
+ end
+end