objspace_dump.c: skip dumping method name if not pure ASCII
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.
This commit is contained in:
parent
5b21e94beb
commit
79406e3600
Notes:
git
2022-07-22 01:44:04 +09:00
@ -547,8 +547,10 @@ dump_object(VALUE obj, struct dump_config *dc)
|
|||||||
}
|
}
|
||||||
if (RTEST(ainfo->mid)) {
|
if (RTEST(ainfo->mid)) {
|
||||||
VALUE m = rb_sym2str(ainfo->mid);
|
VALUE m = rb_sym2str(ainfo->mid);
|
||||||
dump_append(dc, ", \"method\":");
|
if (dump_string_ascii_only(RSTRING_PTR(m), RSTRING_LEN(m))) {
|
||||||
dump_append_string_value(dc, m);
|
dump_append(dc, ", \"method\":");
|
||||||
|
dump_append_string_value(dc, m);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dump_append(dc, ", \"generation\":");
|
dump_append(dc, ", \"generation\":");
|
||||||
dump_append_sizet(dc, ainfo->generation);
|
dump_append_sizet(dc, ainfo->generation);
|
||||||
|
@ -725,4 +725,17 @@ class TestObjSpace < Test::Unit::TestCase
|
|||||||
assert_equal '42', out[2]
|
assert_equal '42', out[2]
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user