Q: In Mac OS X 10.1.x, why does my CFM application crash when
attempting to use the asynchrounous SCSIAction calls?
A: Because of a bug (r. 2649048), the proper Mach-O to CFM glue
is not being created which will cause your application to crash when
SCSIAction attempts to call your CFM callback function.
To workaround this problem, simply implement the code shown below instead
of calling NewSCSICallbackUPP and DisposeSCSICallbackUPP .
Remember to check the Tech Notes released with System Updates and major
OS releases so you can remove this workaround after the underlying bug
is fixed.
SCSICallbackUPP
MyNewSCSICallbackUPP(SCSICallbackProcPtr cfmfp)
{
#if TARGET_RT_MAC_CFM
long systemVersion = 0;
if (Gestalt(gestaltSystemVersion, &systemVersion) == noErr && systemVersion >= 0x1010)
{
UInt32 temp[6] = {0x3D800000, 0x618C0000, 0x800C0000,
0x804C0004, 0x7C0903A6, 0x4E800420};
// Must later dispose of allocated memory
UInt32 * mfp = (UInt32*) NewPtr(sizeof(temp));
mfp[0] = temp[0] | ((UInt32)cfmfp >> 16);
mfp[1] = temp[1] | ((UInt32)cfmfp & 0xFFFF);
mfp[2] = temp[2];
mfp[3] = temp[3];
mfp[4] = temp[4];
mfp[5] = temp[5];
MakeDataExecutable(mfp, sizeof(temp));
return ((SCSICallbackUPP)mfp);
}
else
{
return (NewSCSICallbackUPP(cfmfp));
}
#else
return (NewSCSICallbackUPP(cfmfp));
#endif
}
void
MyDisposeSCSICallbackUPP(SCSICallbackUPP fp)
{
#if TARGET_RT_MAC_CFM
long systemVersion = 0;
if (Gestalt(gestaltSystemVersion, &systemVersion) == noErr && systemVersion >= 0x1010)
{
DisposePtr((char *)fp);
}
else
{
DisposeSCSICallbackUPP(fp);
}
#else
DisposeSCSICallbackUPP(fp);
#endif
}
|
Listing 1. Code to create Mach-O to CFM glue.
|
[Mar 18 2002]
|