Mailing Lists: Apple Mailing Lists

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

Mysterious crash in CFSTR()



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);


To pinpoint the error, I tried this instead:

    Alert1("1: At the top of InitCoreMidiDriver(); about to create client
name string ...");
    strtemp = CFSTR("Bol Processor");
    if (strtemp == NULL)  {
        Alert1("2: Err. CFSTR() returned NULL while creating client name
string.");
        return -1;
    }
    Alert1("3: Created client name string; about to call MIDIClientCreate()
...");
    
    err = MIDIClientCreate(strtemp, CMNotifyCallback, NULL, &CMClient);

My colleague reports that he only sees the first alert message before the
crash, so I am assuming that CFSTR() does not finish before the crash.  Here
is an excerpt from a sample crash log:

Date/Time:      2007-03-08 00:25:21 +0100
OS Version:     10.3.9 (Build 7W98)
Report Version: 2

Exception:  EXC_BAD_ACCESS (0x0001)
Codes:      KERN_INVALID_ADDRESS (0x0001) at 0x436f7265

Thread 0 Crashed:
0   net.sourceforge.bolprocessor    0x00003aac _start + 0x100
1   net.sourceforge.bolprocessor    0x0007f808 InitCoreMidiDriver + 0x30
2   net.sourceforge.bolprocessor    0x000046c8 RegisterMidiDrivers + 0x78
3   net.sourceforge.bolprocessor    0x00003c68 main + 0x90
4   net.sourceforge.bolprocessor    0x00003b28 _start + 0x17c
5   net.sourceforge.bolprocessor    0x000039a8 start + 0x30

PPC Thread State:
  srr0: 0x00003aac srr1: 0x0000d030                vrsave: 0x00000000
    cr: 0x42000222  xer: 0x00000004   lr: 0x00003a84  ctr: 0x90001a44
    r0: 0x00000000   r1: 0xbffffb50   r2: 0xa00016b4   r3: 0x00000000
    r4: 0x00117500   r5: 0x0011755c   r6: 0x8fe505fc   r7: 0x8fe50784
    r8: 0x00000000   r9: 0x436f7265  r10: 0x00000000  r11: 0x436f7265
   r12: 0x90001a44  r13: 0x00000000  r14: 0x00000000  r15: 0x00000000
   r16: 0x00000000  r17: 0x00000000  r18: 0x00000000  r19: 0x00000000
   r20: 0x00000000  r21: 0x00000000  r22: 0x00000000  r23: 0x00000000
   r24: 0x00000000  r25: 0x00000000  r26: 0x00000000  r27: 0x0000000c
   r28: 0x00101df8  r29: 0x00000001  r30: 0x000f6f08  r31: 0x000039c0


The return address in InitCoreMidiDriver (0x0007f808, offset 0x30)
corresponds to the next instruction after the call to
___CFStringMakeConstantString which is what I am guessing the macro CFSTR()
resolves to.  You can see that the stack trace though indicates that the
program seems to be executing in _start again!  (And I just noticed that the
"address" 0x436f7265 is "Core" in ASCII).

The program is a Mach-O executable being built by CodeWarrior 8.3 on OS X
10.2.8.  The program is 100% C and it links to CoreMIDI, CoreAudio, Carbon,
and the System frameworks; crt1.o; and the MSL libraries.  In the
CodeWarrior settings, I have "Reuse Strings", "Make Strings Read-Only", and
"Linker Pools Strings" checked.

I know this is a lot of information, but I am completely mystified by this
bug and since I cannot reproduce it myself, it is all the more confusing.  I
hope that someone here will have some suggestions about what could be wrong.

Thanks in advance!!

Anthony Kozar
anthonykozar AT sbcglobal DOT net
http://anthonykozar.net/

 _______________________________________________
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



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.