[go: up one dir, main page]

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

Fix mutating array during iteration crash #11669

Merged
merged 1 commit into from
Aug 10, 2023
Merged

Fix mutating array during iteration crash #11669

merged 1 commit into from
Aug 10, 2023

Conversation

danielamitay
Copy link
Contributor
@danielamitay danielamitay commented Aug 10, 2023

@paulb777 @morganchen12 @karenyz Please take a look! This PR is a follow-up to #11379

The above linked PR fixes iterating over an array that can be mutated simultaneously elsewhere, but it only fixes it for the experiments array. I have been seeing crashes in my app using FirebaseABTesting on 10.12.0, but for the payloads array.

This file has three locations that iterate over payloads, and the two other locations do [payloads copy] to avoid this problem, and this is the last callsite of payloads in this file without a matching copy to avoid this crash.

Fixes:
Screenshot 2023-08-10 at 12 23 45 PM

Text:

Fatal Exception: NSGenericException
0  CoreFoundation                 0x9cb4 __exceptionPreprocess
1  libobjc.A.dylib                0x183d0 objc_exception_throw
2  CoreFoundation                 0x176920 -[__NSSingleObjectEnumerator init]
3  <redacted>                     0x436a0 ABTExperimentsToClearFromPayloads + 95 (FIRExperimentController.m:95)
4  <redacted>                     0x43db8 -[FIRExperimentController updateExperimentConditionalUserPropertiesWithServiceOrigin:events:policy:lastStartTime:payloads:completionHandler:] + 216 (FIRExperimentController.m:216)
5  <redacted>                     0x43c30 __117-[FIRExperimentController updateExperimentsWithServiceOrigin:events:policy:lastStartTime:payloads:completionHandler:]_block_invoke + 180 (FIRExperimentController.m:180)
6  libdispatch.dylib              0x2320 _dispatch_call_block_and_release
7  libdispatch.dylib              0x3eac _dispatch_client_callout
8  libdispatch.dylib              0x15a64 _dispatch_root_queue_drain
9  libdispatch.dylib              0x16158 _dispatch_worker_thread2
10 libsystem_pthread.dylib        0xda0 _pthread_wqthread
11 libsystem_pthread.dylib        0xb7c start_wqthread

Fixes:

*** Collection <__NSArrayM: 0x2809ab570> was mutated while being enumerated.

FIRExperimentController.m - Line 95
ABTExperimentsToClearFromPayloads + 95
@google-cla
Copy link
google-cla bot commented Aug 10, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@paulb777
Copy link
Member

Thanks @danielamitay 💯

@paulb777 paulb777 merged commit 3df15ba into firebase:master Aug 10, 2023
34 checks passed
@firebase firebase locked and limited conversation to collaborators Sep 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants