Crash when using -[NSMutableAttributedString addAttribute:value:range:]
| Originator: | stefan.munz | ||
| Number: | rdar://11828800 | Date Originated: | 09-Jul-2012 11:50 AM |
| Status: | Open | Resolved: | |
| Product: | iPhone SDK | Product Version: | iOS 6 beta 1 and 2 |
| Classification: | Crash | Reproducible: | Always |
09-Jul-2012 11:50 AM Stefan Munz: Summary: We are seeing a crash in our iOS app on iOS 6 beta 1 and 2 devices. We were able to reproduce it in a sample application that is attached to this bugreport. The crash occurs when we are calling -[NSMutableAttributedString addAttribute:value:range:]. With Zombies enabled we see that the crash is located at -[NSAttributeDictionary isEqualToDictionary:] or -[NSAttributeDictionary count]. As this is a private class we have the impression that this is a memory related bug in your implementation. In Release builds the location seems to be more random. We can avoid the crash by replacing -[NSMutableAttributedString addAttribute:value:range:] with +[NSMutableAttributedString initWithString:attributes] and thus creating a new string every time instead of mutating it. This is also included in the sample project. Steps to Reproduce: Open the sample application, start it in simulator and scroll down. We added a #warning mark where the crash occurs and also added our workaround (as a comment). Expected Results: I would expect to be able to call -[NSMutableAttributedString addAttribute:value:range:] without crashing. This code works fine in iOS 4 and 5. Actual Results: The app is crashing when -[NSMutableAttributedString addAttribute:value:range:] is called. 09-Jul-2012 11:50 AM Stefan Munz: 'NSAttributedStringSerializationBug.zip' and '29f293dd308145c71aa044a28fd26637.log' were 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!