8c3909935e (master): Handle NEWOBJ tracepoints settings fields

0 views
Skip to first unread message

Jean Boussier

unread,
2:15 AM (17 hours ago) 2:15 AM
to ruby...@g.ruby-lang.org
Jean Boussier 2025-11-25 14:06:33 +0000 (Tue, 25 Nov 2025)

New Revision: 8c3909935e

https://github.com/ruby/ruby/commit/8c3909935e

Log:
Handle NEWOBJ tracepoints settings fields

[Bug #21710]

- struct.c: `struct_alloc`

It is possible for a `NEWOBJ` tracepoint call back to write fields
into a newly allocated object before `struct_alloc` had the time
to set the `RSTRUCT_GEN_FIELDS` flags and such.

Hence we can't blindly initialize the `fields_obj` reference to `0`
we first need to check no fields were added yet.

- object.c: `rb_class_allocate_instance`

Similarly, if a `NEWOBJ` tracepoint tries to set fields on the object,
the `shape_id` must already be set, as it's required on T_OBJECT to
know where to write fields.

`NEWOBJ_OF` had to be refactored to accept a `shape_id`.

Modified files:
ext/-test-/tracepoint/tracepoint.c
gc.c
internal/gc.h
object.c
shape.c
shape.h
struct.c
test/-ext-/tracepoint/test_tracepoint.rb
Reply all
Reply to author
Forward
0 new messages