summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorKJ Tsanaktsidis <kj@kjtsanaktsidis.id.au>2023-11-27 20:26:17 +1100
committerKJ Tsanaktsidis <kj@kjtsanaktsidis.id.au>2024-01-11 10:44:57 +1100
commit25f5b83689fc6dd137d45b634a0cd6e8bd024728 (patch)
tree7ed4dfe986acf7dab851bd9c06531a01d03ca74f /internal
parent5906f6a50ed4c6d3e23595ecf5feea615f0965d5 (diff)
Fix crash when printing RGENGC_DEBUG=5 output from GC
I was trying to debug an (unrelated) issue in the GC, and wanted to turn on the trace-level GC output by compiling it with -DRGENGC_DEBUG=5. Unfortunately, this actually causes a crash in newobj_init() because the code there tries to log the obj_info() of the newly created object. However, the object is not actually sufficiently set up for some of the things that obj_info() tries to do: * The instance variable table for a class is not yet initialized, and when using variable-length RVALUES, said ivar table is embedded in as-yet unitialized memory after the struct RValue. Attempting to read this, as obj_info() does, causes a crash. * T_DATA variables need to dereference their ->type field to print out the underlying C type name, which is not set up until newobj_fill() is called. To fix this, create a new method `obj_info_basic`, which dumps out only the parts of the object that are valid before the object is fully initialized. [Fixes #18795]
Diffstat (limited to 'internal')
-rw-r--r--internal/gc.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/internal/gc.h b/internal/gc.h
index 34a6043e8a..2537671855 100644
--- a/internal/gc.h
+++ b/internal/gc.h
@@ -122,6 +122,7 @@ int ruby_get_stack_grow_direction(volatile VALUE *addr);
const char *rb_obj_info(VALUE obj);
const char *rb_raw_obj_info(char *const buff, const size_t buff_size, VALUE obj);
+const char *rb_raw_obj_info_basic(char *const buff, const size_t buff_size, VALUE obj);
size_t rb_size_pool_slot_size(unsigned char pool_id);