Skip to content

Fix RCLASS_WRITE_M_TBL_WORKAROUND to avoid Ruby crash #13988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Jul 23, 2025

On the current master, running test_refinement.rb with GC stress would cause Ruby to crash:

make test-all TESTS='../test/ruby/test_refinement.rb --gc-stress'
TestRefinement#test_refine_alias_in_subclass../internal/class.h:613:
Assertion Failed: RCLASS_WRITE_M_TBL_WORKAROUND:!check_promoted || !RB_OBJ_PROMOTED(klass)

This commit fixes the crash by applying write barrier remember to the klass, which is still a workaround, but avoids crashing Ruby with an assertion.

On the current master, running `test_refinement.rb` with GC stress
would cause Ruby to crash:

```
make test-all TESTS='../test/ruby/test_refinement.rb --gc-stress'
```

```
TestRefinement#test_refine_alias_in_subclass../internal/class.h:613:
Assertion Failed: RCLASS_WRITE_M_TBL_WORKAROUND:!check_promoted || !RB_OBJ_PROMOTED(klass)
```

This commit fixes the crash by applying write barrier remember to the klass,
which is still a workaround, but avoids crashing Ruby with an assertion.

static inline void
RCLASS_WRITE_M_TBL_WORKAROUND(VALUE klass, struct rb_id_table *table, bool check_promoted)
RCLASS_WRITE_M_TBL_WORKAROUND(VALUE klass, struct rb_id_table *table)
Copy link
Member Author

Choose a reason for hiding this comment

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

I remove the argument as it's not used anymore, but I'm not sure if it's against any convention or we actually would want to keep it for documentation purpose...etc. Let me know if I should undo this change.

@st0012
Copy link
Member Author

st0012 commented Jul 23, 2025

This is wrong so I'm closing it now.

@st0012 st0012 closed this Jul 23, 2025
@st0012 st0012 deleted the fix-one-method-table-workaround branch July 23, 2025 16:23
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.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy