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: Mysterious crash in CFSTR()




On Mar 9, 2007, at 10:25 AM, Anthony Kozar wrote:

Hello,

I am porting a Classic application to Carbon and am experiencing a crash
from using CFSTR() that I cannot understand. The program always crashes for
a colleague of mine on three different machines running 10.4, 10.3, and
10.2. From what I can tell from the crash log, it crashes inside of CFSTR()
for him, but it never crashes for me.


In my code that initializes CoreMIDI, I was originally doing the following.

OSStatus InitCoreMidiDriver()
{
    OSStatus err;
    CFStringRef pname, strtemp;

err = MIDIClientCreate(CFSTR("Bol Processor"), CMNotifyCallback, NULL,
&CMClient);


 [snip]

Is InitCoreMidiDriver called more than once? Any chance MIDIClientCreate is releasing its first parameter? CFSTR only allocates a string the first time it is called, so you must either (a) never CFRelease a CFSTR string, or (b) remember to CFRetain it first.

Other possible reasons:
* you've replaced the standard CFAllocator (via CFAllocatorSetDefault (myAllocatorRef)), and it has problems
* good ol' fashioned memory trashing


It looks like __CFStringMakeConstantString can also die if the string has extended characters that aren't MacRoman (obviously not the case here, as you're using only ASCII).

CoreFoundation is open source, so take a peek at CFString.c (in the "CF" project) if you want to see exactly what it does.

- Dan

Dan Wright
banasmoo software



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

This email sent to email@hidden
References: 
 >Mysterious crash in CFSTR() (From: Anthony Kozar <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.