Autoreleasing objects not retained when captured in block
| Originator: | me | ||
| Number: | rdar://11067866 | Date Originated: | 16-Mar-2012 05:46 PM |
| Status: | Closed | Resolved: | 02-Nov-2012 05:05 PM |
| Product: | Mac OS X | Product Version: | 10.7.3 (11D50) |
| Classification: | Crash/Hang/Data Loss | Reproducible: | Always |
Compile the following with:
% clang -framework Foundation -fobjc-arc -o ac autoreleasing-capture.m
Running this will often result in a segfault (but sometimes works, depending on ordering and that stuff). Expected result: Don't segfault, OR compiler should generate a warning if it's invalid to capture an __autoreleasing variable.
The code:
#import <Foundation/Foundation.h>
int main(int argc, const char *argv[])
{
@autoreleasepool {
__autoreleasing id thingy = [NSString stringWithFormat:@"Hi %@", @"folks"];
dispatch_async(dispatch_get_global_queue(0, 0), ^{
NSLog(@"thingy: %@", thingy);
exit(0);
});
}
dispatch_main();
return 0;
}
02-Nov-2012 10:48 AM Apple Developer Bug Reporting Team :
We believe this issue has been addressed in Xcode 4.6 Developer Preview. This is a pre-release version of the Xcode developer toolset for Mac, iPhone, and iPad. It includes the Xcode IDE, iOS Simulator, and all required tools and frameworks for building OS X and iOS apps. Please verify with this release, and update your bug report with the results.
02-Nov-2012 05:05 PM Jonathon Mah:
This issue has been verified as resolved and can be closed.
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!