fix(perf): avoid unsafe NSProxy delegate ivar lookup - #16270
#16270fix(perf): avoid unsafe NSProxy delegate ivar lookup#16270JesusRojass merged 1 commit intofirebase:mainfirebase/firebase-ios-sdk:mainfrom aybarska:performance/proxy-delegate-crashaybarska/firebase-ios-sdk:performance/proxy-delegate-crashCopy head branch name to clipboard
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
|
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. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request addresses a crash in Firebase Performance when instrumenting NSProxy NSURLSession delegates that report a wrapped object's class. It replaces the usage of [GULSwizzler ivarObjectsForObject:] with a custom helper FPRIvarObjectsForProxy that retrieves the runtime class using object_getClass instead of -class. A unit test has been added to verify this fix. Feedback was provided to defensively initialize count to 0 and check if ivars is not NULL before iterating or freeing to avoid potential undefined behavior.
JesusRojass
left a comment
There was a problem hiding this comment.
LGMT
Applying the gemini suggestion would be neat
@aybarska Have you tested this against your repro?
7a7b497 to
f0d80c6
Compare
|
@JesusRojass thx, gemini solution applied Yes, I tested it against the repro and the crash no longer occurs |
JesusRojass
left a comment
There was a problem hiding this comment.
LGTM! Waiting on checks to be done to merge
Discussion
Fixes #16254.
Firebase Performance unwraps NSProxy NSURLSession delegates so it can instrument the wrapped delegate. That lookup previously used generic ivar scanning, which can consult
-class. Some NSProxy implementations forward-classto the wrapped object, so the ivar list can come from a class that does not match the proxy runtime layout.This change uses the proxy object runtime class when scanning ivars, avoiding forwarded
-classand preserving the existing NSProxy delegate instrumentation behavior.Testing
FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT=1 xcodebuild -scheme PerformanceUnit -destination 'platform=iOS Simulator,name=iPhone 17,OS=26.2' -skipPackageUpdates build