Skip to content

BUG: Remove shared separator state from field IO - #151

Merged
dzenanz merged 1 commit into
Kitware:masterfrom
blowekamp:fix-separator-data-race
Nov 3, 2026
Merged

dzenanz merged 1 commit into
Kitware:masterfrom
blowekamp:fix-separator-data-race

Conversation

@blowekamp

Copy link
Copy Markdown
Collaborator

Remove shared separator state from MET_Read and MET_Write to eliminate a data race between calls using separate streams. Preserve the public API and add round-trip checks for default and custom separators.

Root Cause

Both entry points assigned their separator argument to one global variable, also read by MET_SkipToVal. Concurrent calls raced even with identical separators; different separators could corrupt parsing or output. Pass the separator directly to the helper instead.

Validation
  • Built the MetaIO library and testMeta1Utils with AppleClang in Debug mode.
  • testMeta1Utils passed, including round-trip checks for =, :, and |.
  • git diff --check passed.
  • No ThreadSanitizer run was performed.
AI Assistance

AI assistance was used to implement the change, add tests, and inspect repository history.

Concurrent field reads and writes race on the shared separator, even
when operating on separate streams. Keep the separator local to each
call and pass it explicitly to the parsing helper.
@blowekamp
blowekamp marked this pull request as ready for review October 29, 2026 12:11
@blowekamp
blowekamp requested a balanced review from Copilot November 3, 2026 14:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the separator-state change.

No open issues 🎉

What changed in this PR

Removes shared separator state from MetaIO field I/O to eliminate separator-related data races between calls using separate streams, while preserving the public API.

Changes:

  • Uses each call’s separator argument directly in MET_Read, MET_Write, and the internal parsing helper.
  • Adds integer round-trip checks for =, :, and |, including exact serialized output checks.
File Description
src/​tests/​testMeta1Utils.cxx Adds stream-based round-trip tests for three separators.
src/​metaUtils.cxx Removes the global separator and passes call-local values through parsing and writing.

Review effort: Balanced

@blowekamp
blowekamp requested a review from dzenanz November 3, 2026 15:01
@dzenanz
dzenanz merged commit 021db63 into Kitware:master Nov 3, 2026
1 check passed
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.

3 participants