diff options
| author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2025-04-17 22:21:51 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-17 13:21:51 +0000 |
| commit | c4ae6cb5005cfa53be0af466a5619e7455c15744 (patch) | |
| tree | e7ef4d21cab0c9bb4253ca9f00c19c5d73b86e2e /test | |
| parent | 6062c904ae2c4d6a9fafb1a0e22841da85892eea (diff) | |
Prefer `th->ec` for stack base/size. (#13101)
Notes
Notes:
Merged-By: ioquatix <samuel@codeotaku.com>
Diffstat (limited to 'test')
| -rw-r--r-- | test/-ext-/stack/test_stack_overflow.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/-ext-/stack/test_stack_overflow.rb b/test/-ext-/stack/test_stack_overflow.rb new file mode 100644 index 0000000000..eadf6d292a --- /dev/null +++ b/test/-ext-/stack/test_stack_overflow.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true +require 'test/unit' + +class Test_StackOverflow < Test::Unit::TestCase + def test_proc_overflow + omit("Windows stack overflow handling is missing") if RUBY_PLATFORM =~ /mswin|win32|mingw/ + + assert_separately([], <<~RUBY) + # GC may try to scan the top of the stack and cause a SEGV. + GC.disable + require '-test-/stack' + + assert_raise(SystemStackError) do + Thread.alloca_overflow + end + RUBY + end + + def test_thread_stack_overflow + omit("Windows stack overflow handling is missing") if RUBY_PLATFORM =~ /mswin|win32|mingw/ + + assert_separately([], <<~RUBY) + require '-test-/stack' + GC.disable + + thread = Thread.new do + Thread.current.report_on_exception = false + Thread.alloca_overflow + end + + assert_raise(SystemStackError) do + thread.join + end + RUBY + end + + def test_fiber_stack_overflow + omit("Windows stack overflow handling is missing") if RUBY_PLATFORM =~ /mswin|win32|mingw/ + + assert_separately([], <<~RUBY) + require '-test-/stack' + GC.disable + + fiber = Fiber.new do + Thread.alloca_overflow + end + + assert_raise(SystemStackError) do + fiber.resume + end + RUBY + end +end |
