[missing-sync-palmos-dev-talk] Using Cocoa in a Carbon conduit
Stuart A. Malone
samalone at llamagraphics.com
Fri May 26 07:28:44 PDT 2006
Joe, I think you may have been onto something when you wrote:
> Is there any need to bundle all the Cocoa functionality into a
> seperate bundle and load it lazily like that mentioned
> http://developer.apple.com/documentation/Cocoa/Conceptual/
> CarbonCocoaDoc/Articles/LazyCocoaLoading.html
> in order to let the conduit work under Palm Desktop?
>
> I ask because it says in the article, "You may want to use lazy
> initialization if the Cocoa functionality that you need is not always
> required by all users or your application uses CFM."
I believe that I have just run into this issue. Palm Desktop crashes
when it attempts to unload my mixed Carbon/Cocoa bundle under
Panther. I'm still researching the issue, but I wanted to mention it
right away so that we can put our heads together and work out a
solution.
The crash looks like this:
Thread 3 Crashed:
0 libobjc.A.dylib 0x9086be80 _objc_trap + 0
1 libobjc.A.dylib 0x9086be14 _objc_fatal + 0x48
2 libobjc.A.dylib 0x90867c44 _objc_fatalHeader + 0x44
3 dyld 0x8fe182c0
call_funcs_for_remove_image + 0x8c
4 dyld 0x8fe13220 _dyld_unlink_module +
0xcc
5 libSystem.B.dylib 0x9003db4c NSUnLinkModule + 0x68
6 com.apple.CoreFoundation 0x90236290
_CFBundleDYLDUnloadBundle + 0x3c
7 com.apple.CoreFoundation 0x9021da00
CFBundleUnloadExecutable + 0xe8
8 Conduit Manager 0x0040dcc0 0x405000 + 0x8cc0
Some searching turned up a couple of interesting messages from
Apple's mailing lists:
http://lists.apple.com/archives/cocoa-dev/2001/Dec/msg00592.html
http://lists.apple.com/archives/carbon-development/2003/Nov/
msg01760.html
The Cocoa documentation <http://developer.apple.com/documentation/
Cocoa/Conceptual/LoadingCode/LoadingCode.html> from 2003-01-13 says:
Due to a limitation in the Objective-C runtime system, at the time
of writing there is no way to unload Cocoa loadable bundles.
There is a similar warning at the bottom of <http://
developer.apple.com/documentation/Cocoa/Conceptual/LoadingCode/
Concepts/CFNSBundle.html>:
Because of a limitation in the Objective-C runtime system, NSBundle
cannot unload executable code. Since CFBundle does not know about
Objective-C symbols, do not use the CFBundle loading and unloading
routines on NSBundle objects. You can, however, create a CFBundle
object for a Cocoa bundle and use the other routines—unrelated to
loading and unloading—without trouble.
So I think the solution is probably to follow Apple's instructions
for "Loading Cocoa Lazily Into Your Carbon Application":
<http://developer.apple.com/documentation/Cocoa/Conceptual/
CarbonCocoaDoc/Articles/LazyCocoaLoading.html>
First, I'm going to see if I can isolate and eliminate our conduit's
dependencies on Cocoa, but if that's not possible, I'll try following
Apple's instructions for lazy loading.
I'll let you all know how it goes. I'd also welcome thoughts on
other solutions.
Best wishes,
--Stuart A. Malone
Llamagraphics, Inc.
Makers of Life Balance personal coaching software
http://www.llamagraphics.com/
More information about the missing-sync-palmos-dev-talk
mailing list