Registering a YAML converter while another thread serializes no longer throws #356

Merged
claude merged 2 commits from feature/354-yaml-converter-race into develop 2026-11-06 16:07:16 -05:00
Owner

YamlSerializer keeps its shared converters in a static list. AddConverter added to it with no lock, while GetDeserializer and GetSerializer enumerated it, so a YAML read at the same moment as a registration could throw InvalidOperationException: Collection was modified. Develop run 1282 failed this way in YamlInputFormatterTests.

The list is now guarded by a lock, and the builders enumerate a snapshot taken under it: the same pattern JsonSerializer already uses. The new YamlSerializerProcessWideTests adds 400 distinct converters on 8 threads while 8 more threads serialize, in the non-parallel process-wide collection.

Checked:

  • The new test failed 3 of 5 runs without the fix and passed 5 of 5 with it.
  • Whole solution on Linux, Category!=RequiresDocker: 47 projects green, 0 warnings. csharpier and the link check pass.

Closes #354

🤖 Generated with Claude Code

https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK

`YamlSerializer` keeps its shared converters in a static list. `AddConverter` added to it with no lock, while `GetDeserializer` and `GetSerializer` enumerated it, so a YAML read at the same moment as a registration could throw `InvalidOperationException: Collection was modified`. Develop run 1282 failed this way in `YamlInputFormatterTests`. The list is now guarded by a lock, and the builders enumerate a snapshot taken under it: the same pattern `JsonSerializer` already uses. The new `YamlSerializerProcessWideTests` adds 400 distinct converters on 8 threads while 8 more threads serialize, in the non-parallel process-wide collection. Checked: - The new test failed 3 of 5 runs without the fix and passed 5 of 5 with it. - Whole solution on Linux, `Category!=RequiresDocker`: 47 projects green, 0 warnings. csharpier and the link check pass. Closes #354 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
Closes #354

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
The changelog names the YAML converter-list fix
Some checks failed
Build / Pack and Push NuGet Packages (dns-core) (pull_request) Successful in -2m12s
Build / Build Binary (macos-amd64) (pull_request) Successful in -31s
Build / Build Binary (macos-arm64) (pull_request) Successful in -53s
Build / Build Binary (windows-amd64) (pull_request) Successful in -1m14s
Build / Pack and Push NuGet Packages (dns-server) (pull_request) Successful in -2m8s
Build / Build Binary (linux-amd64) (pull_request) Successful in -1m8s
Build / Build Binary (linux-arm64) (pull_request) Successful in -1m5s
Build / Smoke Test the Windows Binary (pull_request) Successful in 16s
Build / Build Arch Linux Packages (pull_request) Successful in -2m30s
Build / Build and Push Image (pull_request) Successful in -2m38s
Build / Build and Test Deb and RPM Packages (pull_request) Successful in -36s
Build / Publish Release (pull_request) Successful in -2m41s
Build / Pipeline (pull_request) Successful in 0s
Build / Pipeline (push) Has been cancelled
Build / Stage Draft Release (push) Has been cancelled
Build / Build Binary (linux-amd64) (push) Has been cancelled
Build / Build Binary (linux-arm64) (push) Has been cancelled
Build / Build Binary (macos-amd64) (push) Has been cancelled
Build / Build Binary (macos-arm64) (push) Has been cancelled
Build / Build Binary (windows-amd64) (push) Has been cancelled
Build / Build Arch Linux Packages (push) Has been cancelled
Build / Build and Test Deb and RPM Packages (push) Has been cancelled
Build / Build and Push Image (push) Has been cancelled
Build / Pack and Push NuGet Packages (common) (push) Has been cancelled
Build / Pack and Push NuGet Packages (dhcp) (push) Has been cancelled
Build / Pack and Push NuGet Packages (dns-core) (push) Has been cancelled
Build / Pack and Push NuGet Packages (dns-server) (push) Has been cancelled
Build / Smoke Test the Windows Binary (push) Has been cancelled
Build / Publish Release (push) Has been cancelled
Build / Test .NET (push) Has been cancelled
a30497163f
Refs #354

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
claude merged commit 25d23862d5 into develop 2026-11-06 16:07:16 -05:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lantea-one/ninlil!356
No description provided.