From 79406e3600862bbb6dcdd7c5ef8de1978e6f916c Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 21 Jul 2022 14:50:44 +0200 Subject: objspace_dump.c: skip dumping method name if not pure ASCII MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sidekiq has a method named `❨╯°□°❩╯︵┻━┻`which corrupts heap dumps. Normally we could just dump is as is since it's valid UTF-8 and need no escaping. But our code to escape control characters isn't UTF-8 aware so it's more complicated than it seems. Ultimately since the overwhelming majority of method names are pure ASCII, it's not a big loss to just skip it. --- test/objspace/test_objspace.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test') diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb index 1392447e4f..59ab8e7adc 100644 --- a/test/objspace/test_objspace.rb +++ b/test/objspace/test_objspace.rb @@ -725,4 +725,17 @@ class TestObjSpace < Test::Unit::TestCase assert_equal '42', out[2] end end + + def test_utf8_method_names + obj = ObjectSpace.trace_object_allocations do + utf8_❨╯°□°❩╯︵┻━┻ + end + assert_nil JSON.parse(ObjectSpace.dump(obj))["method"] + end + + private + + def utf8_❨╯°□°❩╯︵┻━┻ + "1" + "2" + end end -- cgit v1.2.3