Bug #21172
closedRace condition in `register_fstring`
Description
This is a rare bug with very low criticality, but it can cause occasional CI failures. I leave it to branch maintainers to decide if it's worth backporting or not.
Timeline¶
- A
"foo" oid=1
string is interned. -
"foo" oid=1
is no longer referenced and will be swept in the future. - Another
"foo" oid=2
string is interned. -
register_fstring
finds"foo" oid=1
, but since it is about to be swept, removes it fromfstring_table
and insert"foo" oid=2
instead. -
"foo" oid=1
is swept, since it has theRSTRING_FSTR
flag, ast_delete
is issued infstring_table
which removes"foo" oid=2
.
Unfortunately, I couldn't come up with a minimal reproduction for this, but it did reproduce consistently with a large amount of tests and a very specific seed.
Consequence¶
This has little to no consequence on real world code. It just breaks a few ruby tests that is attempting to ensure some strings were interned.
Example:
1) Failure:
JSONParserTest#test_freeze [/tmp/ruby/src/trunk/test/json/json_parser_test.rb:361]:
Expected "foo" (oid=416) to be the same as "foo" (oid=424).
make: *** [uncommon.mk:953: yes-test-all] Error 1
Updated by byroot (Jean Boussier) 29 days ago
- Status changed from Open to Closed
Applied in changeset git|c224ca4feaff20cab03d76439bcbfb35d4e2f6b1.
Fix a race condition with interned strings sweeping.
[Bug #21172]
This fixes a rare CI failure.
The timeline of the race condition is:
- A
"foo" oid=1
string is interned. -
"foo" oid=1
is no longer referenced and will be swept in the future. - Another
"foo" oid=2
string is interned. -
register_fstring
finds"foo" oid=1
, but since it is about to be swept,
removes it fromfstring_table
and insert"foo" oid=2
instead. -
"foo" oid=1
is swept, since it has theRSTRING_FSTR
flag,
ast_delete
is issued infstring_table
which removes"foo" oid=2
.
I don't know how to reproduce this bug consistently in a single test
case.
Updated by nagachika (Tomoyuki Chikanaga) 18 days ago
- Backport changed from 3.1: WONTFIX, 3.2: WONTFIX, 3.3: REQUIRED, 3.4: REQUIRED to 3.1: WONTFIX, 3.2: WONTFIX, 3.3: DONE, 3.4: REQUIRED
ruby_3_3 726bff43b462d2a1b0bc93299cf031202f7fe7a1 merged revision(s) c224ca4feaff20cab03d76439bcbfb35d4e2f6b1.
Updated by byroot (Jean Boussier) 18 days ago
- Backport changed from 3.1: WONTFIX, 3.2: WONTFIX, 3.3: DONE, 3.4: REQUIRED to 3.1: WONTFIX, 3.2: WONTFIX, 3.3: DONE, 3.4: DONE