macOS Sierra: SFChooseIdentityPanel leaks window and views, leaves dangling NSTableView data source
| Originator: | sdy | ||
| Number: | rdar://29409207 | Date Originated: | 2016-11-28 |
| Status: | Open | Resolved: | |
| Product: | macOS SDK | Product Version: | 10.12.1 |
| Classification: | Crash | Reproducible: | Always |
Summary: The views provided by SecurityInterface leak memory in 10.12. In our case, SFChooseIdentityPanel was observed to retain an NSWindow and several views inside that window and never release them. This leak affects any application that presents a SFChooseIdentityPanel, including system apps like Safari. The leaked window remains in the window list and contains an NSTableView whose data source is the SFChooseIdentityPanel itself. The table view will try to calculate its size in response to screen changes (e.g. a display being connected or disconnected), and in response to scroll bar style changes (always visible/visible when scrolling) even if the window is explicitly closed by app code. When an app links against a 10.11+ SDK, this does *not* lead to a crash because NSTableView's dataSource property is a zeroing weak reference. The property is an unowned (but not zeroing) reference for apps which link against an *older* SDK, so after the SFChooseIdentityPanel has been deallocated either of the above events will crash the app. Steps to Reproduce: 1. Unzip SFChooseIdentityPanel-crash.zip on a machine running macOS Sierra and run the included .app or build and run the Xcode project. 2. Follow the instructions and observe the crash. 3. Change the Xcode project to target a newer SDK, build, and observe that the app no longer crashes but did leak memory. 4. Also run `swift SFChooseIdentityPanel-leaks.swift` and observe the breakdown of leaks. Expected Results: Using SFChooseIdentityPanel or other classes provided by SecurityInterface doesn't introduce leaks or crashes. Actual Results: Using SFChooseIdentityPanel always results in memory leaks, and causes crashes when used on Sierra with an app built against the 10.10 SDK. Version: Version 8.1 (8B62) Notes: There appear to be other lifetime issues with SFChooseIdentityPanel, too (e.g. if I don't keep a reference to it until after its callback returns, I also get a crash). I suspect that the other classes in this framework are also leaky/crashy. Configuration: 10.12.1 (16B2657) Leak: Any SDK, including the current 10.12.1 SDK Crash: 10.10 SDK
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!