NSKeyedUnarchiver is not retaining replacement object from delegate

Originator:jeremyfoo
Number:rdar://10896508 Date Originated:
Status:Closed Resolved:
Product:Other Product Version:
Classification: Reproducible:Always
 
21-Feb-2012 02:43 AM Jeremy Foo:
Summary:
NSKeyedUnarchiverDelegate specifies a method (unarchiver:didDecodeObject:) that allows for an object to be substituted for the one that was decoded.

This object, if newly created with a retain count of 1 cannot be autoreleased. This is so because the unarchiver doesn't seem to retain this new substitute object but will release it upon deallocation.

Attached is sample open source project that currently makes extensive use of this replacement system.

In particular refer to the MNUnarchiver.m file on line 134. By removing the "autorelease" this project no longer crashes.

Steps to Reproduce:
1. Run Mac/iOS project of the attached workspace.
2. Archive something.
3. Unarchive something.

Expected Results:
The attributed string will unarchive without problems.

Actual Results:
The project crashes citing an EXEC_BAD_ACCESS. Further investigation will reveal that the decoded object has become a zombie prior to the final deallocation of the MNUnarchiver class.

Regression:

Notes:
Checking for leaks with Instruments shows that despite removing the autorelease, no leaks occur which supports the hypothesis that somewhere down the line, the substitute object sent by the delegate is not being retained.

21-Feb-2012 02:43 AM Jeremy Foo:
'MNcoder.zip' was successfully uploaded
(http://www.github.com/echoz/MNcoder)

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!