Skip to content
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

Potential data race in Storage method #13369

Closed
jesus-mg-ios opened this issue Jul 24, 2024 · 5 comments · Fixed by #13428
Closed

Potential data race in Storage method #13369

jesus-mg-ios opened this issue Jul 24, 2024 · 5 comments · Fixed by #13428
Assignees

Comments

@jesus-mg-ios
Copy link

jesus-mg-ios commented Jul 24, 2024

Description

image

Reproducing the issue

Define a storage instance and call storage.reference(forURL: String) from multiple threads and sometimes the warn in Xcode happened.
image

 let task = Task {
            try await withCheckedThrowingContinuation { continuation in
                let storageReference = self.storage.reference(forURL: referencePath)
                storageReference.getData() { data, error in
                    if let error {
                        continuation.resume(throwing: error)
                        return
                    }
                    guard let data, !data.isEmpty else {
                        continuation.resume(throwing: Error.error)
                        return
                    }
                    continuation.resume(returning: data)
                }
            } as Data
        }

 return await task.value

Firebase SDK Version

10.25.0

Xcode Version

15.2

Installation Method

Swift Package Manager

Firebase Product(s)

Storage

Targeted Platforms

iOS

Relevant Log Output

No response

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet
Replace this line with the contents of your Package.resolved.

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
Replace this line with the contents of your Podfile.lock!
@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@paulb777
Copy link
Member

@jesus-mg-ios Thanks for the report. Would you check if #13381 fixes your test case?

@paulb777
Copy link
Member

Nevermind. static methods in an actor aren't thread safe. A fix will take more investigation.

@jesus-mg-ios
Copy link
Author

Maybe a dispatch queue async with a barrier flag could do the trick.

@paulb777
Copy link
Member

paulb777 commented Jul 25, 2024

Thanks. First, we'll see if we can address by migrating those internal APIs to Swift concurrency sometime in the next few weeks.

@paulb777 paulb777 self-assigned this Jul 26, 2024
@firebase firebase locked and limited conversation to collaborators Sep 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
4 participants