Only test on known good platforms. (#13123)

This commit is contained in:
Samuel Williams 2025-04-18 01:19:05 +09:00 committed by GitHub
parent c4ae6cb500
commit 06a7b3c144
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2025-04-17 16:19:22 +00:00
Merged-By: ioquatix <samuel@codeotaku.com>
2 changed files with 19 additions and 6 deletions

View File

@ -17,8 +17,19 @@ stack_alloca_overflow(VALUE self)
return Qnil;
}
static VALUE
asan_p(VALUE klass)
{
#if defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer)
return Qtrue;
#else
return Qfalse;
#endif
}
void
Init_stack(VALUE klass)
{
rb_define_singleton_method(rb_cThread, "alloca_overflow", stack_alloca_overflow, 0);
rb_define_singleton_method(rb_cThread, "asan?", asan_p, 0);
}

View File

@ -2,9 +2,15 @@
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/
def setup
omit "Stack overflow tests are not supported on this platform: #{RUBY_PLATFORM.inspect}" unless RUBY_PLATFORM =~ /x86_64-linux|darwin/
require '-test-/stack'
omit "Stack overflow tests are not supported with ASAN" if Thread.asan?
end
def test_overflow
assert_separately([], <<~RUBY)
# GC may try to scan the top of the stack and cause a SEGV.
GC.disable
@ -17,8 +23,6 @@ class Test_StackOverflow < Test::Unit::TestCase
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
@ -35,8 +39,6 @@ class Test_StackOverflow < Test::Unit::TestCase
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