{{ message }}
Repository navigation
ICU-23352 Reset initOnce before clearing the collation root singleton - #4259
Open
ManoharPaturi wants to merge 1 commit into
Open
ManoharPaturi wants to merge 1 commit into
ManoharPaturi wants to merge 1 commit into
Conversation
Member
uprv_collation_root_cleanup() cleared rootSingleton before resetting initOnce. A concurrent CollationRoot::getRoot() that had already passed umtx_initOnce() could then dereference the freed singleton. Reset initOnce first so concurrent callers are directed through initialization instead of the cleared pointer.
ManoharPaturi
force-pushed
the
icu-23352-collation-root-cleanup-order
branch
from
October 8, 2026 16:57
1d65f4c to
2460e8b
Compare
|
Notice: the branch changed across the force-push!
~ Your Friendly Jira-GitHub PR Checker Bot |
Author
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
uprv_collation_root_cleanup() cleared rootSingleton before resetting initOnce. A concurrent CollationRoot::getRoot() that had already passed umtx_initOnce() could then dereference the freed singleton during library teardown. This change resets initOnce first, so concurrent callers are directed through initialization instead of reaching for the cleared pointer, as prescribed in the ticket.
The analysis and the fix direction come from ticket ICU-23352; an earlier pull request #3921 proposed the same change; the ticket was moved to Accepted while that PR was open, and after the discussion of the u_cleanup() threading contract there the PR went quiet and was closed without a technical rejection.
The regression test
TestCollationRootCleanupRace(ported from #3921) is included intsmthred.cpp/tsmthred.h: it runs ten rounds ofu_cleanup()followed by concurrentCollationRoot::getRoot()reader threads, failing under TSAN/ASAN on unfixed code.Testing
The race window is not deterministically observable in a regular test run, so this change ships without a new test. The ordering change is two lines, and the full rbbi and collation suites pass locally with it applied.