Skip to content

Commit 44bf94a

Browse files
committed
Include ivar name and class in class/module ivar-get isolation violation (fast path)
The attr-index fast path (rb_ivar_get_at, used by JITs) emitted a bare isolation-violation message without naming the ivar or class, unlike the generic rb_ivar_lookup path. Interpolate the ivar name and class (via rb_class_path to avoid to_s recursion) so warnings from the fast path also identify the offending (@Iv from Class).
1 parent aaeb451 commit 44bf94a

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

variable.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1552,8 +1552,17 @@ rb_ivar_get_at(VALUE obj, attr_index_t index, ID id)
15521552
VALUE val = rb_imemo_fields_ptr(fields_obj)[index];
15531553

15541554
if (UNLIKELY(rb_ractor_isolation_check_active()) && !rb_ractor_shareable_p(val)) {
1555+
/* Use rb_class_path() (pure C, reads the internal name
1556+
* slot) rather than passing `obj` through %PRIsVALUE.
1557+
* %PRIsVALUE calls `to_s` on its argument, and if `obj`
1558+
* is a module/class that delegates `to_s` through
1559+
* method_missing to an internal proxy (e.g.
1560+
* ActiveSupport::Deprecation::DeprecatedConstantProxy),
1561+
* the warning emission re-triggers the same ivar access,
1562+
* recursing until the stack overflows. */
15551563
rb_ractor_isolation_violation(
1556-
"can not get unshareable values from instance variables of classes/modules from non-main Ractors");
1564+
"can not get unshareable values from instance variables of classes/modules from non-main Ractors (%"PRIsVALUE" from %"PRIsVALUE")",
1565+
rb_id2str(id), rb_class_path(obj));
15571566
}
15581567

15591568
return val;

0 commit comments

Comments
 (0)