Skip to content

fix(dotnet): synchronize EnsureStrippedTokenizer to prevent race cond… - #1020

Merged
NandhaKishorM merged 1 commit into
NandhaKishorM:mainfrom
LEVELING2108:fix/dotnet-tokenizer-race-condition
Oct 8, 2026
Merged

NandhaKishorM merged 1 commit into
NandhaKishorM:mainfrom
LEVELING2108:fix/dotnet-tokenizer-race-condition

Conversation

@LEVELING2108

Copy link
Copy Markdown
Contributor

…ition on parallel test runs

What

Why

How it was verified

python tests/test_router.py
ruff check laya/ --select=E9,F63,F7,F82,F401,F811 --line-length=120

Checklist

  • Focused on one change (split unrelated work into another PR)
  • Rebased on the latest main
  • Tests pass locally
  • Docs or examples updated when the public API changed

Fixes #

@NandhaKishorM
NandhaKishorM merged commit bde4bd9 into NandhaKishorM:main Oct 8, 2026
30 of 34 checks passed
@NandhaKishorM

Copy link
Copy Markdown
Owner

Merged, and thank you for splitting it out.

This is the hunk I asked about on #977 and #982: it was riding along in both, byte-identical, in PRs about tool selection and training. Double-checked locking around the stripped-tokenizer cache is a real fix and it belongs here, on its own, where a .NET reviewer sees it.

The bug is the ordinary one for this pattern: two test classes constructing tokenizers in parallel both find the cache invalid, both write, and one reads a half-written file. Re-checking IsCacheValid inside the lock is what makes the second writer a no-op rather than a racing one.

One note for next time rather than a change request: the body here is still the unfilled template, with What, Why and How it was verified empty, and the commands listed are tests/test_router.py and the Python linter, neither of which exercises .NET. The change is small enough to read, so I took it, but on a concurrency fix the body is where I would normally look for how you reproduced the race.

All 85 suites pass on the merged tree. The .NET lane is advisory here, as #671 settled, so it did not gate this.

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