Fix thread safety issues in UnitTests#415
Merged
ZachNagengast merged 3 commits intoargmaxinc:swift-6from Feb 23, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves reliability of callback-driven unit tests by removing a data race in the segment discovery callback and slightly refactoring test setup for clarity.
Changes:
- Added
os.lockimport and usedOSAllocatedUnfairLockto protect the shareddiscoveredSegmentscollection in the VAD callback test. - Refactored
audioFilePathretrieval intestCallbackWithEarlyStopping()to happen earlier in the test setup.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ZachNagengast
approved these changes
Feb 17, 2026
9e56a90 to
6fc544e
Compare
naykutguven
added a commit
to naykutguven/WhisperKit
that referenced
this pull request
Mar 3, 2026
* Fix thread safety issues in UnitTests * Fix thread safety error in TestUtils * Move helper class inside the util method
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.
This pull request improves the thread safety and reliability of the
segmentDiscoveryCallbacktest inUnitTests.swiftby introducing a lock to protect shared state. Additionally, it makes a minor import update and refactors how the audio file path is retrieved.Thread safety improvements:
discoveredSegmentswith anOSAllocatedUnfairLock-protected array to ensure thread-safe access when segments are discovered and appended in the callback. All subsequent accesses todiscoveredSegmentsare now done through the lock.General refactoring and minor changes:
audioFilePathto earlier in the test setup for clarity and to avoid redundant code.os.lockimport to support the new locking mechanism.