-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Runtime: Don't leak bridged object when value-to-bridged-object cast fails. #2326
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
Conversation
@swift-ci Please test and merge |
This doesn't look right. It looks like the inner cast inherits DestroyOnFailure from the outside. Should this function be doing precisely what _dynamicCastValueToClassExistentialViaObjCBridgeable() does? |
(This function and _dynamicCastValueToClassExistentialViaObjCBridgeable() look like the only relevant uses of bridgeToObjectiveC, so there aren't any similar bugs elsewhere in the file.) |
@gparker42 We need to unconditionally clean up the result if it isn't consumed as part of the cast result. Since it's returned from the Note that when we recursively call |
@ddunbar @mxcl @rballard These test failures look familiar?
|
@moiseev Is this related to the problem we spoke about? |
@ddunbar looks exactly like the failure I saw. Should be fixed by now. |
…fails. Fixes a leak when a bridgeable value type is dynamically cast to a class type, and the cast fails, for instance: ``` let x: Any = "string" x is NSNumber ``` We would fail to release the bridging object after attempting the cast.
@swift-ci Please test and merge |
Ah, I mis-read that flags mask operation. But why does the cleanup in |
Fair point. One difference is that |
Fixes a leak when a bridgeable value type is dynamically cast to a class type, and the cast fails, for instance:
We would fail to release the bridging object after attempting the cast.