summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2025-09-24 15:37:56 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2025-09-24 16:59:57 -0400
commit44d0b019548a26c289d60eb3699f75dc208e5481 (patch)
tree53ef4d908e524b080bd02284cc7d99994ad61c3e
parentde92dd9a63f2065253cee082e3408de935313acd (diff)
Don't require to set PC before allocating hidden object
ZJIT doesn't set PC before rb_set_ivar(), and that allocates a managed ID table. Was a false positive from gc_validate_pc().
-rw-r--r--gc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/gc.c b/gc.c
index 507d24d215..da74c24c3f 100644
--- a/gc.c
+++ b/gc.c
@@ -974,9 +974,12 @@ static inline void
gc_validate_pc(VALUE obj)
{
#if RUBY_DEBUG
+ // IMEMOs and objects without a class (e.g managed id table) are not traceable
+ if (RB_TYPE_P(obj, T_IMEMO) || !CLASS_OF(obj)) return;
+
rb_execution_context_t *ec = GET_EC();
const rb_control_frame_t *cfp = ec->cfp;
- if (!RB_TYPE_P(obj, T_IMEMO) && cfp && VM_FRAME_RUBYFRAME_P(cfp) && cfp->pc) {
+ if (cfp && VM_FRAME_RUBYFRAME_P(cfp) && cfp->pc) {
const VALUE *iseq_encoded = ISEQ_BODY(cfp->iseq)->iseq_encoded;
const VALUE *iseq_encoded_end = iseq_encoded + ISEQ_BODY(cfp->iseq)->iseq_size;
RUBY_ASSERT(cfp->pc >= iseq_encoded, "PC not set when allocating, breaking tracing");