Crash returning NSError UIDocument's loadFromContents:ofType:error: under ARC.
| Originator: | apontious | ||
| Number: | rdar://11931030 | Date Originated: | 7/21/2012 |
| Status: | Closed | Resolved: | |
| Product: | iPad SDK | Product Version: | 5.1 |
| Classification: | Crash/Hang/Data Loss | Reproducible: | Always |
Summary: Steps to Reproduce: - git clone https://github.com/apontious/reignOfError.git - Open iOS project "Reign of Error" in latest release Xcode, Xcode 4.3.3, on latest release version of OS, which is 10.7.4 Lion - Build and run in Simulator Expected Results: - Application runs fine. Actual Results: - Application crashes because NSError returned from ErrorDocument subclass of UIDocument in loadFromContents:ofType:error: appears to be getting released in the frameworks, then used. Here's what I get from Instruments (I've added spaces to make the columns line up): # Category Event Type RefCt Timestamp Size Responsible Library Responsible Caller 0 NSError Malloc 1 00:01.592.995 32 Foundation +[NSError errorWithDomain:code:userInfo:] 1 NSError Autorelease <null> 00:01.593.005 0 Foundation +[NSError errorWithDomain:code:userInfo:] 2 NSError Retain 2 00:01.593.009 0 Reign of Error -[ErrorDocument loadFromContents:ofType:error:] 3 NSError Autorelease <null> 00:01.593.016 0 Reign of Error -[ErrorDocument loadFromContents:ofType:error:] 4 NSError Release 1 00:01.593.023 0 GraphicsServices GSEventRunModal 5 NSError Release 0 00:01.593.024 0 GraphicsServices GSEventRunModal 6 NSError Zombie -1 00:01.593.601 0 libsystem_c.dylib start_wqthread I may just be using the APIs wrong, but I thought you could just set an NSError** parameter to a newly-created NSError instance, and it would be retained/autoreleased to have a lifespan long enough for all its clients to use. The only way to make it stick around long enough is if I keep my own strong reference around. There's a commented-out line in ErrorDocument which does just that, and it keeps it from crashing. But that seems like an unnecessary workaround. Regression: - I haven't tried this before, so I don't know if it's a regression from anything.
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!
I added a comment to Apple 8/2012:
I am not seeing it with iOS 10 6.0 beta 3.
This issue has been verified as resolved and can be closed.