|
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
On Sep 8, 2009, at 11:29 PM, John Engelhart wrote:
That is a different issue, though. In that case, you are explicitly taking a GC controlled bit of memory and passing it to something explicitly non-GC. IN particular, it is an issue for which interior pointers are orthogonal. The tools could do a better job of warning when that particular boundary is crossed. The problem, though, is not one -- directly -- of interior pointers. It is of pointer escaping. Once a pointer escapes from scanned memory -- and a call to a non-GC aware API is a form of escape, most often harmless -- all bets are off unless the escape point is marked with a "hey, collector, don't collect this pointer until I say it is OK for you to collect this pointer". That is done via CFRetain/CFRelease or via -disableCollectorForPointer: and -enableCollectorForPointer:. There probably should be synonymous API in objc/objc-auto.h, frankly (<rdar://problem/7208041>). So, given: const char *p = [@"String Me!" UTF8String]; printf("%s", p); Or: const char *p = NSAllocateCollectable(...); someRandomNonGCCLibraryFunc(p); The problem is the same. Once 'p' crosses the boundary into that API, all bets are off as far as GC is concerned. In particular, the function might store away the pointer somewhere. It might XOR it with something prior to storing it (a surprisingly common thing to do). Or it might decide to store it in some non-pointer aligned fashion. Effectively, ever GC'd application is running dual mode. All of the CF and Objective-C bits are running GC'd and all of the pure-C goop is running non-GC'd. At the boundary, you need to match impedance. That means from GC -> Non-GC, you need to tell the collector that outside forces are colluding to keep the pointer alive. For Non-GC -> GC, it means you might need to drop a free() into your otherwise GC clean code. Interior pointers, in this context, only extend the range of the problem to include situations such as printf() where the function does not internally keep the pointer around.
No -- I'm saying that every boundary between GC'd code and non-GC'd code is a point of impedance mismatch that needs to, potentially, be considered. Most of the time, "it just works". Most of the time, it is quite natural that the design/architecture of a body of code is such that a particular set of state -- set of objects -- survives across such call boundaries without a second thought from the developer.
The code will be available Real Soon Now (There is a placeholder for autozone-141 on the open source page -- http://www.opensource.apple.com/release/mac-os-x-106/). If you have patches or test cases, file a bug! (Common refrain, I know) http://bugreport.apple.com/ b.bum |
_______________________________________________ Do not post admin requests to the list. They will be ignored. Objc-language mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
| References: | |
| >Does Mac OS X support interior pointers? (From: John Engelhart <email@hidden>) | |
| >Re: Does Mac OS X support interior pointers? (From: Quincey Morris <email@hidden>) | |
| >Re: Does Mac OS X support interior pointers? (From: John Engelhart <email@hidden>) | |
| >Re: Does Mac OS X support interior pointers? (From: Hamish Allan <email@hidden>) | |
| >Re: Does Mac OS X support interior pointers? (From: John Engelhart <email@hidden>) | |
| >Re: Does Mac OS X support interior pointers? (From: Hamish Allan <email@hidden>) | |
| >Re: Does Mac OS X support interior pointers? (From: John Engelhart <email@hidden>) | |
| >Re: Does Mac OS X support interior pointers? (From: Hamish Allan <email@hidden>) | |
| >Re: Does Mac OS X support interior pointers? (From: John Engelhart <email@hidden>) | |
| >Re: Does Mac OS X support interior pointers? (From: Bill Bumgarner <email@hidden>) | |
| >Re: Does Mac OS X support interior pointers? (From: John Engelhart <email@hidden>) |
| Home | Archives | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2011 Apple Inc. All rights reserved.