Skip to content

Conversation

@etiennebarrie
Copy link
Member

Improve the messages of exceptions raised by the Ractor implementation.

When an object fails to be made shareable with Ractor.make_shareable or when an unshareable object is accessed through module constants or module instance variables, the error message now includes the chain of references that leads to the unshareable value.

Improve the messages of exceptions raised by the Ractor implementation.

When an object fails to be made shareable with `Ractor.make_shareable`
or when an unshareable object is accessed through module constants or
module instance variables, the error message now includes the chain of
references that leads to the unshareable value.
@etiennebarrie etiennebarrie force-pushed the ractor-error-reference-chain branch from d37bed4 to 89a62f7 Compare January 19, 2026 14:29
!RB_OBJ_SHAREABLE_P(block_self)) {
if (!rb_ractor_shareable_p_continue(block_self, chain)) {
if (chain) {
if (NIL_P(*chain)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we duplicating the chain_append logic here?

"Proc's self is not shareable: %" PRIsVALUE,
self);
if (chain) {
if (NIL_P(*chain)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here?

" from block self #<Foo @ivar={}>\n" \
" from hash default value\n" \
" from instance variable @ivar\n" \
" from instance variable @foo", %q{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The chain approach makes sense to me, but I'm finding the error message a little hard to parse - it's not immediately obvious to me from the message what objects the ivars are attached to, or where the hash values are coming from. Is it worth using rb_inspect or rb_obj_as_string here or is the performance an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants