Crash using dispatch I/O channel in URLProtocol
| Originator: | green | ||
| Number: | rdar://16902536 | Date Originated: | 13-May-2014 |
| Status: | Open | Resolved: | |
| Product: | OS X SDK | Product Version: | |
| Classification: | Reproducible: | Always |
Summary: Using a dispatch I/O channel to implement a URLProtocol causes memory corruption if the I/O channel is released before the URLProtocol is deallocated. Steps to Reproduce: Run the attached Xcode project on OS X 10.9. Note: Enabling the "Guard Malloc" configuration makes the crash happen reliably instead of randomly. Expected Results: Actual Results: Version: Xcode 5.1 on OS X 10.9 or iOS 7 Notes: Configuration: It happens in the OS X 10.9 SDK and the iOS 7 SDK. Attachments: 'ConnectionCrash.zip' was successfully uploaded.
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!
Workaround
The workaround is to store the I/O channel as an ivar of the NSURLProtocol subclass. It's still ok to close the channel, just not to release the reference to it until the URLProtocol is deallocated.