Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: crash in __static_initialization_and_destruction on 10.3.9 but not 10.4.4?




On Feb 6, 2006, at 11:44 AM, John C. Daub wrote:

on 2/6/06 10:26 AM, Gen Kiyooka at email@hidden wrote:

The other factor to consider is that the 3 different dylib models
that are
available all have different life cycle models.  I wrote a series of
test
programs that explored the loading/unloading cycle for dynamic libs,
frameworks and bundles and they have different unloading properties.

Hrm... I did not know this.

All that I saw did make me wonder what was going on in the runtime, what was
causing things to behave like they did. I still wonder if that's happening
and somehow playing subtle evil things.


My suggestion is to hook the mach load/unload entry points and dump
some stuff to the console log to make sure your frameworks are loading
and unloading the way you expect them to.

I admit I don't know how to do this. Would you be so kind as to enlighten
me? :-)

Good question. Since you're an ex-Codewarrior man, I wrote my samples
with CodeWarrior 8. It's using pragmas which may be CW specific.
I think I discovered the hook/entry points while browsing the sources for dyld.
Either that or spelunking in MSL.


Here's the code snippet:

#pragma export off

extern void module_bind(void);
#pragma CALL_ON_MODULE_BIND module_bind
void module_bind(void)
{
	// INSTANT_CRASH; // WORKS!
	printf(MYDLL "::module_bind() mach-o dyld event\n");

}

extern void module_load(void);
#pragma CALL_ON_LOAD module_load
void module_load(void)
{
	// INSTANT_CRASH; // WORKS!
	printf(MYDLL "::module_load() mach-o dyld event\n");
}

extern void module_unload(void);
#pragma CALL_ON_UNLOAD module_unload

void module_unload(void)
{
	printf(MYDLL "::module_unload() mach-o dyld event\n");
	// INSTANT_CRASH; // WORKS
}

extern void module_term(void);
#pragma CALL_ON_MODULE_TERM module_term

// Metrowerks supplied function for destructing global static objects
extern "C" void __destroy_global_chain(void);

void module_term(void)
{
	// INSTANT_CRASH; // WORKS!
	printf(MYDLL "::module_term() mach-o dyld event\n");
	printf(MYDLL "::__destroy_global_chain START\n");
	__destroy_global_chain(); /* call all C++ static destructors */
	printf(MYDLL "::__destroy_global_chain END\n");
}


_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to email@hidden
References: 
 >Re: crash in __static_initialization_and_destruction on 10.3.9 but not 10.4.4? (From: "John C. Daub" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.