Skip to content

Fix possible concurrent mutation crash #925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- Fix inconsistent unused parameter results when the function is declared in a file that is a member of multiple targets.
- Fix inconsistent results caused by identical extensions declared in different modules.
- Static `@_dynamicReplacement` members are now retained.
- Fix possible concurrent mutation crash when accessing filename matching configuration options.

## 3.1.0 (2025-04-05)

Expand Down
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ var targets: [PackageDescription.Target] = [
dependencies: [
.target(name: "PeripheryKit"),
.target(name: "ProjectDrivers"),
.target(name: "Configuration"),
],
path: "Tests/Shared"
),
Expand Down
39 changes: 2 additions & 37 deletions Sources/Configuration/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,6 @@ public final class Configuration {
}
}

public func reset() {
settings.forEach { $0.reset() }
}

// MARK: - Helpers

public func apply<T: Equatable>(_ path: KeyPath<Configuration, Setting<T>>, _ value: T) {
Expand All @@ -186,35 +182,9 @@ public final class Configuration {
}
}

private var _indexExcludeMatchers: [FilenameMatcher]?
public var indexExcludeMatchers: [FilenameMatcher] {
if let _indexExcludeMatchers {
return _indexExcludeMatchers
}

let matchers = buildFilenameMatchers(with: indexExclude)
_indexExcludeMatchers = matchers
return matchers
}

private var _retainFilesMatchers: [FilenameMatcher]?
public var retainFilesMatchers: [FilenameMatcher] {
if let _retainFilesMatchers {
return _retainFilesMatchers
}

let matchers = buildFilenameMatchers(with: retainFiles)
_retainFilesMatchers = matchers
return matchers
}

public func resetMatchers() {
_indexExcludeMatchers = nil
_retainFilesMatchers = nil
}

public lazy var indexExcludeMatchers: [FilenameMatcher] = buildFilenameMatchers(with: indexExclude)
public lazy var retainFilesMatchers: [FilenameMatcher] = buildFilenameMatchers(with: retainFiles)
public lazy var reportExcludeMatchers: [FilenameMatcher] = buildFilenameMatchers(with: reportExclude)

public lazy var reportIncludeMatchers: [FilenameMatcher] = buildFilenameMatchers(with: reportInclude)

// MARK: - Private
Expand Down Expand Up @@ -255,7 +225,6 @@ protocol AbstractSetting {
var hasNonDefaultValue: Bool { get }
var wrappedValue: Value { get }

func reset()
func assign(_ value: Any)
}

Expand Down Expand Up @@ -293,10 +262,6 @@ protocol AbstractSetting {
public func assign(_ newValue: Any) {
value = setter(newValue) ?? defaultValue
}

func reset() {
wrappedValue = defaultValue
}
}

private let filePathSetter: (Any) -> FilePath? = { value in
Expand Down
Loading