Skip to content

Conversation

composerinteralia
Copy link
Contributor

StringScanner holds the string being scanned, and a regex for methods
like match?. Triggering the write barrier for those allows us to mark
this as WB protected.

StringScanner holds the string being scanned, and a regex for methods
like `match?`. Triggering the write barrier for those allows us to mark
this as WB protected.
@kou
Copy link
Member

kou commented May 25, 2025

Do we also need to change

#define CLEAR_NAMED_CAPTURES(s) ((s)->regex = Qnil)
?

@composerinteralia
Copy link
Contributor Author

nil won't ever get collected, so I don't think there's anything special we need to do there. Even if we did this through RB_OBJ_WRITE I don't think that would change anything because we don't trigger the write barrier for special consts like nil (see https://github.com/ruby/ruby/blob/87d340f0e129ecf807e3be35d67fda1ad6f40389/include/ruby/internal/gc.h#L788-L789)

@kou
Copy link
Member

kou commented May 25, 2025

OK. Let's merge this.

@kou kou merged commit 32fec70 into ruby:master May 25, 2025
38 checks passed
matzbot pushed a commit to ruby/ruby that referenced this pull request Jun 6, 2025
(ruby/strscan#156)

StringScanner holds the string being scanned, and a regex for methods
like `match?`. Triggering the write barrier for those allows us to mark
this as WB protected.

ruby/strscan@32fec70407
sms021019 pushed a commit to sms021019/ruby that referenced this pull request Jun 17, 2025
(ruby/strscan#156)

StringScanner holds the string being scanned, and a regex for methods
like `match?`. Triggering the write barrier for those allows us to mark
this as WB protected.

ruby/strscan@32fec70407
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