diff options
| author | nagachika <nagachika@ruby-lang.org> | 2024-03-31 17:37:01 +0900 |
|---|---|---|
| committer | nagachika <nagachika@ruby-lang.org> | 2024-03-31 17:37:01 +0900 |
| commit | 27606daf8efeb0ae6d0590a2c9bb1c5aae07f140 (patch) | |
| tree | be81bc12dd31060be820baa502e66a741fd4b43f /test/ruby | |
| parent | 4f3ed07d5bfd581b630e4afc8b9bb170ce781e7f (diff) | |
merge revision(s) ac0163949a6ee678dfccec9f6e56422b91e5f0a9,01fd262e62076277a41af72ea13f20deb1b462a2: [Backport #20245]
Compile code without Symbol GC always
---
symbol.c | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
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")
---
symbol.c | 17 ++++++++++-------
test/ruby/test_module.rb | 8 ++++++++
2 files changed, 18 insertions(+), 7 deletions(-)
Diffstat (limited to 'test/ruby')
| -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 dd8cc471d0..6129f0cbbe 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) |
