instantiating classes globally in a startup item (was: Re: IOServiceMatching produces oddly inert dictionary for startup item)
instantiating classes globally in a startup item (was: Re: IOServiceMatching produces oddly inert dictionary for startup item)
- Subject: instantiating classes globally in a startup item (was: Re: IOServiceMatching produces oddly inert dictionary for startup item)
- From: Pete Gontier <email@hidden>
- Date: Wed, 08 Dec 2004 11:46:19 -0800
circa 12/8/04 9:47 AM, "Garth Cummings" <email@hidden> wrote:
>> The real problem is that IOServiceGetMatchingServices is failing with a
>> return value of 0x10000003 and I can't figure out why. This error code
>> apparently has something to do with Mach IPC, but I don't know much more
>> than that even after searching the Darwin sources for clues.
> If you search for 0x10000003 on <http://developer.apple.com>, you'll
> get these two hits that should clear things up:
>
> Retain Counts of io_object_t Objects in IOKit.framework
> <http://developer.apple.com/qa/qa2001/qa1195.html>
Thanks for reading through that mess to find the real problem. I was about
to start another thread. :-) The relevant passage from the Q&A seems to be:
> If you get the famous 0x10000003 (MACH_SEND_INVALID_DEST) return code back
> from an IOKit.framework function, that's referring to a stale io_object_t,
> not the underlying kernel object.
This is an excellent clue which cracks the case. The only io_object_t
involved here is the master port passed to IOServiceGetMatchingServices.
Assuming it's stale, the question becomes how and why. I am of course
obtaining the master port from IOMasterPort. This call is wrapped into the
constructor of a C++ class which I instantiate globally. Such objects are
supposed to be constructed by the C++ runtime library before they are used.
When I launch the app from the terminal, this works; I can tell because I
added a log statement to the constructor. However, when the app is launched
as a startup item, the constructor does NOT run (ever). So rather than a
stale io_object_t, I'm passing an uninitialized io_object_t. The question
then becomes why the constructor is not running. What about being launched
as a startup item inhibits the C++ runtime library from doing its job? I
don't have an acute need to know this because I can just pass NULL to
IOServiceGetMatchingServices since it occurs to me this app requires Panther
anyway. But I would still like to know what the problem is, because if I
can't instantiate classes globally in general, I'm going to have to take a
census of all my code to make sure I'm not unknowingly bitten by this
problem elsewhere.
--
Pete Gontier
http://www.m-audio.com/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden