Skip to content
Closed
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
3 changes: 3 additions & 0 deletions FirebaseAuth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Unreleased
- [fixed] Replaced unsafe uses of `os_unfair_lock` (#14548).

# 11.9.0
- [changed] Using reCAPTCHA Enterprise and Firebase Auth requires reCAPTCHA
Enterprise 18.7.0 or later.
Expand Down
6 changes: 3 additions & 3 deletions FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
private var instances: [String: Auth] = [:]

/// Lock to manage access to the instances array to avoid race conditions.
private var instancesLock: os_unfair_lock = .init()
private let instancesLock = OSAllocatedUnfairLock()

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / integration-tests (AuthenticationExampleUITests)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / integration-tests (AuthenticationExampleUITests)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / integration-tests (AuthenticationExampleUITests)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / integration-tests (ObjCApiTests)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / integration-tests (ObjCApiTests)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / integration-tests (ObjCApiTests)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / integration-tests (SwiftApiTests)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / integration-tests (SwiftApiTests)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, macOS spmbuildonly)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, macOS spmbuildonly)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, macOS spmbuildonly)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, macOS spmbuildonly)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, macOS spmbuildonly)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, macOS spmbuildonly)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, watchOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, watchOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, watchOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, watchOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, watchOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, watchOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, tvOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, tvOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, tvOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, tvOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, tvOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, tvOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, visionOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, visionOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, visionOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-13, Xcode_15.2, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-13, Xcode_15.2, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-13, Xcode_15.2, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-13, Xcode_15.2, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-13, Xcode_15.2, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-13, Xcode_15.2, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-13, Xcode_15.2, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-13, Xcode_15.2, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-14, Xcode_15.4, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-14, Xcode_15.4, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-14, Xcode_15.4, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-14, Xcode_15.4, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-14, Xcode_15.4, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-14, Xcode_15.4, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-14, Xcode_15.4, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-14, Xcode_15.4, iOS spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, catalyst spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, catalyst spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, catalyst spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, catalyst spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, catalyst spm)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 36 in FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, catalyst spm)

cannot find 'OSAllocatedUnfairLock' in scope

// MARK: - Initializers

Expand All @@ -58,10 +58,10 @@
// MARK: - AuthProvider conformance

@discardableResult func auth() -> Auth {
os_unfair_lock_lock(&instancesLock)
instancesLock.lock()

// Unlock before the function returns.
defer { os_unfair_lock_unlock(&instancesLock) }
defer { instancesLock.unlock() }

if let instance = instances[app.name] {
return instance
Expand Down
3 changes: 3 additions & 0 deletions FirebaseFunctions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Unreleased
- [fixed] Replaced unsafe uses of `os_unfair_lock` (#14548).

# 11.9.0
- [fixed] Fixed App Check token reporting to enable differentiating outdated
(`MISSING`) and inauthentic (`INVALID`) clients; see [Monitor App Check
Expand Down
6 changes: 3 additions & 3 deletions FirebaseFunctions/Sources/Functions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
private static var instances: [String: [Functions]] = [:]

/// Lock to manage access to the instances array to avoid race conditions.
private static var instancesLock: os_unfair_lock = .init()
private static let instancesLock = OSAllocatedUnfairLock()

Check failure on line 59 in FirebaseFunctions/Sources/Functions.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-14, Xcode_15.4, iOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 59 in FirebaseFunctions/Sources/Functions.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-14, Xcode_15.4, iOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 59 in FirebaseFunctions/Sources/Functions.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-14, Xcode_15.4, iOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 59 in FirebaseFunctions/Sources/Functions.swift

View workflow job for this annotation

GitHub Actions / spm-integration (macos-14, Xcode_15.4)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 59 in FirebaseFunctions/Sources/Functions.swift

View workflow job for this annotation

GitHub Actions / spm-integration (macos-14, Xcode_15.4)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 59 in FirebaseFunctions/Sources/Functions.swift

View workflow job for this annotation

GitHub Actions / spm-integration (macos-14, Xcode_15.4)

cannot find 'OSAllocatedUnfairLock' in scope

/// The custom domain to use for all functions references (optional).
let customDomain: String?
Expand Down Expand Up @@ -304,10 +304,10 @@
guard let app else {
fatalError("`FirebaseApp.configure()` needs to be called before using Functions.")
}
os_unfair_lock_lock(&instancesLock)
instancesLock.lock()

// Unlock before the function returns.
defer { os_unfair_lock_unlock(&instancesLock) }
defer { instancesLock.unlock() }

if let associatedInstances = instances[app.name] {
for instance in associatedInstances {
Expand Down
3 changes: 3 additions & 0 deletions FirebaseStorage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Unreleased
- [fixed] Replaced unsafe uses of `os_unfair_lock` (#14548).

# 11.1.0
- [fixed] Fix a potential data race in Storage initialization. (#13369)

Expand Down
6 changes: 3 additions & 3 deletions FirebaseStorage/Sources/Storage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,13 @@
private var instances: [String: Storage] = [:]

/// Lock to manage access to the instances array to avoid race conditions.
private var instancesLock: os_unfair_lock = .init()
private let instancesLock = OSAllocatedUnfairLock()

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / testapp-integration (iOS, macos-15)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, visionOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, visionOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, tvOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, tvOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, watchOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, watchOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.2, watchOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / sample (macos-15, Xcode_16.2)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / sample (macos-15, Xcode_16.2)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / sample (macos-13, Xcode_15.2)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / sample (macos-13, Xcode_15.2)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / sample (macos-14, Xcode_15.4)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, catalyst)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, iOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, iOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, iOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, iOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, iOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, visionOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, visionOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, visionOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-14, Xcode_15.4, iOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, macOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, macOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, macOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, macOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-13, Xcode_15.2, iOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-13, Xcode_15.2, iOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-13, Xcode_15.2, iOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-13, Xcode_15.2, iOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / storage-integration-tests (ObjC)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / storage-integration-tests (ObjC)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / storage-integration-tests (ObjC)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / storage-integration-tests (Swift)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / storage-integration-tests (Swift)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 252 in FirebaseStorage/Sources/Storage.swift

View workflow job for this annotation

GitHub Actions / storage-integration-tests (Swift)

cannot find 'OSAllocatedUnfairLock' in scope

private init() {}

func storage(app: FirebaseApp, bucket: String) -> Storage {
os_unfair_lock_lock(&instancesLock)
defer { os_unfair_lock_unlock(&instancesLock) }
instancesLock.lock()
defer { instancesLock.unlock() }

if let instance = instances[bucket] {
return instance
Expand Down
1 change: 1 addition & 0 deletions FirebaseVertexAI/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Unreleased
- [feature] The Vertex AI SDK no longer requires `@preconcurrency` when imported in Swift 6.
- [feature] The Vertex AI Sample App now includes an image generation example.
- [fixed] Replaced unsafe uses of `os_unfair_lock` (#14548).

# 11.9.0
- [feature] **Public Preview**: Added support for generating images using the
Expand Down
13 changes: 5 additions & 8 deletions FirebaseVertexAI/Sources/VertexAI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,17 @@

let apiConfig: APIConfig

/// Lock to manage access to the `instances` array to avoid race conditions.
private static let instancesLock = OSAllocatedUnfairLock()

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / testapp-integration (iOS, macos-15)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / sample (macos-15, Xcode_16.2)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / sample (macos-15, Xcode_16.2)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / sample (macos-13, Xcode_15.2)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / sample (macos-13, Xcode_15.2)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / sample (macos-14, Xcode_15.4)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / sample (macos-14, Xcode_15.4)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, catalyst)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, catalyst)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, catalyst)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, iOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, visionOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-14, Xcode_15.4, iOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-14, Xcode_15.4, iOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-14, Xcode_15.4, iOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-13, Xcode_15.2, iOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-13, Xcode_15.2, iOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-13, Xcode_15.2, iOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, watchOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, watchOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, tvOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, tvOS)

cannot find 'OSAllocatedUnfairLock' in scope

Check failure on line 128 in FirebaseVertexAI/Sources/VertexAI.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, tvOS)

cannot find 'OSAllocatedUnfairLock' in scope

#if compiler(>=6)
/// A map of active `VertexAI` instances keyed by the `FirebaseApp` name and the `location`, in
/// the format `appName:location`.
private nonisolated(unsafe) static var instances: [InstanceKey: VertexAI] = [:]

/// Lock to manage access to the `instances` array to avoid race conditions.
private nonisolated(unsafe) static var instancesLock: os_unfair_lock = .init()
#else
/// A map of active `VertexAI` instances keyed by the `FirebaseApp` name and the `location`, in
/// the format `appName:location`.
private static var instances: [InstanceKey: VertexAI] = [:]

/// Lock to manage access to the `instances` array to avoid race conditions.
private static var instancesLock: os_unfair_lock = .init()
#endif

let location: String?
Expand All @@ -149,10 +146,10 @@
fatalError("No instance of the default Firebase app was found.")
}

os_unfair_lock_lock(&instancesLock)
instancesLock.lock()

// Unlock before the function returns.
defer { os_unfair_lock_unlock(&instancesLock) }
defer { instancesLock.unlock() }

let instanceKey = InstanceKey(appName: app.name, location: location, apiConfig: apiConfig)
if let instance = instances[instanceKey] {
Expand Down
Loading