mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 13:34:17 +02:00
Prefer th->ec
for stack base/size. (#13101)
This commit is contained in:
parent
6062c904ae
commit
c4ae6cb500
Notes:
git
2025-04-17 13:22:09 +00:00
Merged-By: ioquatix <samuel@codeotaku.com>
4 changed files with 86 additions and 6 deletions
53
test/-ext-/stack/test_stack_overflow.rb
Normal file
53
test/-ext-/stack/test_stack_overflow.rb
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue