diff options
| author | NARUSE, Yui <nurse@users.noreply.github.com> | 2024-03-21 09:05:07 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-21 00:05:07 +0000 |
| commit | b2c2702f20abfd4bb5f38cad60170e2bbb3adff9 (patch) | |
| tree | 71379ea0d5f4d11c2b3416d719a1098735b3ddcd /test/ruby/test_module.rb | |
| parent | 00cb72157a60c20a9b9d9fe81fc974ea83d672b4 (diff) | |
merge revision(s) 01fd262e62076277a41af72ea13f20deb1b462a2: [Backport #20245] (#10307)
Fix crash when checking symbol encoding
[Bug #20245]
We sometimes pass in a fake string to sym_check_asciionly. This can crash
if sym_check_asciionly raises because it creates a CFP with the fake
string as the receiver which will crash if GC tries to mark the CFP.
For example, the following script crashes:
GC.stress = true
Object.const_defined?("\xC3")
Diffstat (limited to 'test/ruby/test_module.rb')
| -rw-r--r-- | test/ruby/test_module.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index ca15746002..4722fa22e0 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -253,6 +253,14 @@ class TestModule < Test::Unit::TestCase assert_operator(Math, :const_defined?, "PI") assert_not_operator(Math, :const_defined?, :IP) assert_not_operator(Math, :const_defined?, "IP") + + # Test invalid symbol name + # [Bug #20245] + EnvUtil.under_gc_stress do + assert_raise(EncodingError) do + Math.const_defined?("\xC3") + end + end end def each_bad_constants(m, &b) |
