8000 Fix too early writebarrier in tally_up by jhawthorn · Pull Request #13629 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content
8000

Fix too early writebarrier in tally_up #13629

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

Merged
merged 1 commit into from
Jun 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix too early writebarrier in tally_up
After returning from the callback in st_update is the point that the
hash table may be resized, which could trigger a GC and mark the table
being used for the tally.

    RUBY_GC_LIBRARY=wbcheck WBCHECK_VERIFY_AFTER_WB=1 ./miniruby -e '(0...100).map(&:to_s).tally'
  • Loading branch information
jhawthorn committed Jun 16, 2025
commit 18cdd235bccf4d23ff1f076b802f88713e59fc66
5 changes: 3 additions & 2 deletions enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -1215,14 +1215,15 @@ tally_up(st_data_t *group, st_data_t *value, st_data_t arg, int existing)
RB_OBJ_WRITTEN(hash, Qundef, tally);
}
*value = (st_data_t)tally;
if (!SPECIAL_CONST_P(*group)) RB_OBJ_WRITTEN(hash, Qundef, *group);
return ST_CONTINUE;
}

static VALUE
rb_enum_tally_up(VALUE hash, VALUE group)
{
rb_hash_stlike_update(hash, group, tally_up, (st_data_t)hash);
if (!rb_hash_stlike_update(hash, group, tally_up, (st_data_t)hash)) {
RB_OBJ_WRITTEN(hash, Qundef, group);
}
return hash;
}

Expand Down
0