Skip to content

fix: Use a per-call buffer in RuleBasedCollator.GetSortKey - #240

Open
imnasnainaec wants to merge 1 commit into
masterfrom
fix-238-sortkey-thread-safety
Open

imnasnainaec wants to merge 1 commit into
masterfrom
fix-238-sortkey-thread-safety

Conversation

@imnasnainaec

@imnasnainaec imnasnainaec commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #238.

GetSortKey wrote the native sort key into a shared instance field, so concurrent calls on one collator silently returned keys built from other threads' strings. Each call now uses its own buffer.

🤖 Generated with Claude Code


Devin review: https://app.devin.ai/review/sillsdev/icu-dotnet/pull/240

GetSortKey wrote the native sort key into a shared mutable instance field, so
concurrent calls on one collator interleaved into the same array and silently
returned keys assembled from other threads' strings. The buffer is now local to
the call. Growth also allocates exactly the size ucol_getSortKey reports instead
of doubling until it fits.

Fixes #238

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@imnasnainaec imnasnainaec self-assigned this Sep 21, 2026
@imnasnainaec
imnasnainaec marked this pull request as ready for review September 21, 2026 15:06
@github-actions

Copy link
Copy Markdown

Test Results

       8 files  ±  0     648 suites  ±0   8s ⏱️ -1s
   441 tests +  2     437 ✔️ +  2      4 💤 ±0  0 ±0 
3 616 runs  +16  3 406 ✔️ +16  210 💤 ±0  0 ±0 

Results for commit a0c497b. ± Comparison against base commit e596389.

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.

RuleBasedCollator.GetSortKey silently corrupts keys when called concurrently (shared keyData buffer)

1 participant