|
|
2fb58f |
From 0ade5611df9f981005eed32b369d1e699e520221 Mon Sep 17 00:00:00 2001
|
|
|
2fb58f |
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
|
|
|
2fb58f |
Date: Thu, 10 Feb 2022 13:26:44 +0100
|
|
|
2fb58f |
Subject: [PATCH] Don't query `RubyVM::FrozenCore` for class path.
|
|
|
2fb58f |
|
|
|
2fb58f |
The `RubyVM::FrozenCore` class path is corrupted during GC cycle and
|
|
|
2fb58f |
returns random garbage, which might result in segfault.
|
|
|
2fb58f |
|
|
|
2fb58f |
But since it is easy to detect the `RubyVM::FrozenCore`, just provide
|
|
|
2fb58f |
the class path explicitly as a workaround.
|
|
|
2fb58f |
|
|
|
2fb58f |
Other possibility would be to ignore `RubyVM::FrozenCore` simlarly as
|
|
|
2fb58f |
TracePoint API does:
|
|
|
2fb58f |
|
|
|
2fb58f |
https://github.com/ruby/ruby/blob/46f6575157d4c2f6bbd5693896e26a65037e5552/vm_trace.c#L411
|
|
|
2fb58f |
---
|
|
|
2fb58f |
vm.c | 10 +++++++++-
|
|
|
2fb58f |
1 file changed, 9 insertions(+), 1 deletion(-)
|
|
|
2fb58f |
|
|
|
2fb58f |
diff --git a/vm.c b/vm.c
|
|
|
2fb58f |
index 8ce8b279d4..3d189fa63a 100644
|
|
|
2fb58f |
--- a/vm.c
|
|
|
2fb58f |
+++ b/vm.c
|
|
|
2fb58f |
@@ -479,7 +479,15 @@ rb_dtrace_setup(rb_execution_context_t *ec, VALUE klass, ID id,
|
|
|
2fb58f |
}
|
|
|
2fb58f |
type = BUILTIN_TYPE(klass);
|
|
|
2fb58f |
if (type == T_CLASS || type == T_ICLASS || type == T_MODULE) {
|
|
|
2fb58f |
- VALUE name = rb_class_path(klass);
|
|
|
2fb58f |
+ VALUE name = Qnil;
|
|
|
2fb58f |
+ /*
|
|
|
2fb58f |
+ * Special treatment for rb_mRubyVMFrozenCore wchi is broken by GC.
|
|
|
2fb58f |
+ * https://bugs.ruby-lang.org/issues/18257
|
|
|
2fb58f |
+ */
|
|
|
2fb58f |
+ if (klass == rb_mRubyVMFrozenCore)
|
|
|
2fb58f |
+ name = rb_str_new_cstr("RubyVM::FrozenCore");
|
|
|
2fb58f |
+ else
|
|
|
2fb58f |
+ name = rb_class_path(klass);
|
|
|
2fb58f |
const char *classname, *filename;
|
|
|
2fb58f |
const char *methodname = rb_id2name(id);
|
|
|
2fb58f |
if (methodname && (filename = rb_source_location_cstr(&args->line_no)) != 0) {
|
|
|
2fb58f |
--
|
|
|
2fb58f |
2.34.1
|
|
|
2fb58f |
|