How to debug and fix backwards compatibility issues?

HI…

I have recently found that a project I built with Xcode 2.1 on Tiger crashes on 10.3.8 and 10.3.9.

I have absolutely no idea how to debug this, let alone fix it.

Anyone have an idea about this? I tried Jonn8’s suggestion about 10.2 involving sudo gcc_select 3.3, but that did not help.

Here’s the crash log from a friend’s 10.3.8 system.


Date/Time: 2005-07-16 10:01:02 -0400
OS Version: 10.3.8 (Build 7U16)
Report Version: 2

Command: Cast Away
Path: /Installers/Cast Away.app/Contents/MacOS/Cast Away
Version: 1.0 (1.0b1)
PID: 1885
Thread: 0

Exception: EXC_BREAKPOINT (0x0006)
Code[0]: 0x00000001
Code[1]: 0x90a5c740

Thread 0 Crashed:
0 com.apple.Foundation 0x90a5c740 _NSRaiseError + 0xf8
1 com.apple.Foundation 0x90a5c624 +[NSException raise:format:] + 0x2c
2 com.apple.Foundation 0x909f785c _decodeObjectBinary + 0x684
3 com.apple.Foundation 0x90a0e7ac -[NSKeyedUnarchiver
_decodeArrayOfObjectsForKey:] + 0x29c
4 com.apple.Foundation 0x90a06070 -[NSArray initWithCoder:] + 0x170
5 com.apple.Foundation 0x909f78c8 _decodeObjectBinary + 0x6f0
6 com.apple.Foundation 0x909fb22c _decodeObject + 0x98
7 com.apple.AppKit 0x92df3414 -[NSView initWithCoder:] + 0xf8
8 com.apple.Foundation 0x909f78c8 _decodeObjectBinary + 0x6f0
9 com.apple.Foundation 0x909fb22c _decodeObject + 0x98
10 com.apple.AppKit 0x92ef5918 -[NSTabViewItem initWithCoder:] +
0xc8
11 com.apple.Foundation 0x909f78c8 _decodeObjectBinary + 0x6f0
12 com.apple.Foundation 0x90a0e7ac -[NSKeyedUnarchiver
_decodeArrayOfObjectsForKey:] + 0x29c
13 com.apple.Foundation 0x90a06070 -[NSArray initWithCoder:] + 0x170
14 com.apple.Foundation 0x909f78c8 _decodeObjectBinary + 0x6f0
15 com.apple.Foundation 0x909fb22c _decodeObject + 0x98
16 com.apple.AppKit 0x92f3d8d4 -[NSTabView initWithCoder:] + 0x98
17 com.apple.Foundation 0x909f78c8 _decodeObjectBinary + 0x6f0
18 com.apple.Foundation 0x909fb22c _decodeObject + 0x98
19 com.apple.AppKit 0x92e28cf4 -[NSResponder initWithCoder:] + 0x60
20 com.apple.AppKit 0x92df3374 -[NSView initWithCoder:] + 0x58
21 com.apple.Foundation 0x909f78c8 _decodeObjectBinary + 0x6f0
22 com.apple.Foundation 0x909fb22c _decodeObject + 0x98
23 com.apple.AppKit 0x92e28cf4 -[NSResponder initWithCoder:] + 0x60
24 com.apple.AppKit 0x92df3374 -[NSView initWithCoder:] + 0x58
25 com.apple.AppKit 0x92e78640 -[NSScrollView initWithCoder:] +
0x60
26 com.apple.Foundation 0x909f78c8 _decodeObjectBinary + 0x6f0
27 com.apple.Foundation 0x909fb22c _decodeObject + 0x98
28 com.apple.AppKit 0x92e28cf4 -[NSResponder initWithCoder:] + 0x60
29 com.apple.AppKit 0x92df3374 -[NSView initWithCoder:] + 0x58
30 com.apple.AppKit 0x92e4f3e4 -[NSClipView initWithCoder:] + 0x3c
31 com.apple.Foundation 0x909f78c8 _decodeObjectBinary + 0x6f0
32 com.apple.Foundation 0x909fb22c _decodeObject + 0x98
33 com.apple.AppKit 0x92e28cf4 -[NSResponder initWithCoder:] + 0x60
34 com.apple.AppKit 0x92df3374 -[NSView initWithCoder:] + 0x58
35 com.apple.AppKit 0x92e2c1ac -[NSControl initWithCoder:] + 0x3c
36 com.apple.AppKit 0x92e9338c -[NSTableView initWithCoder:] + 0x90
37 com.apple.Foundation 0x909f78c8 _decodeObjectBinary + 0x6f0
38 com.apple.Foundation 0x909fb22c _decodeObject + 0x98
39 com.apple.AppKit 0x92e222e0 -[NSActionCell initWithCoder:] +
0x1a0
40 com.apple.AppKit 0x92e48f7c -[NSButtonCell initWithCoder:] +
0x44
41 com.apple.Foundation 0x909f78c8 _decodeObjectBinary + 0x6f0
42 com.apple.Foundation 0x909fb22c _decodeObject + 0x98
43 com.apple.AppKit 0x92e2682c -[NSNibConnector initWithCoder:] +
0x84
44 com.apple.Foundation 0x909f78c8 _decodeObjectBinary + 0x6f0
45 com.apple.Foundation 0x90a0e7ac -[NSKeyedUnarchiver
_decodeArrayOfObjectsForKey:] + 0x29c
46 com.apple.Foundation 0x90a06070 -[NSArray initWithCoder:] + 0x170
47 com.apple.Foundation 0x909f78c8 _decodeObjectBinary + 0x6f0
48 com.apple.Foundation 0x909fb22c _decodeObject + 0x98
49 com.apple.AppKit 0x92e64898 -[NSIBObjectData initWithCoder:] +
0xcc
50 com.apple.Foundation 0x909f78c8 _decodeObjectBinary + 0x6f0
51 com.apple.Foundation 0x909fb22c _decodeObject + 0x98
52 com.apple.AppKit 0x92ee42a4 loadNib + 0xa8
53 com.apple.AppKit 0x92e3b55c +[NSBundle(NSNibLoading)
_loadNibFile:nameTable:withZone:ownerBundle:] + 0x2e8
54 com.apple.AppKit 0x92eba3f4 +[NSBundle(NSNibLoading)
loadNibFile:externalNameTable:withZone:] + 0x9c
55 com.apple.AppKit 0x92ecbbe8 +[NSBundle(NSNibLoading)
loadNibNamed:owner:] + 0x174
56 com.apple.AppKit 0x92eba25c NSApplicationMain + 0x174
57 com.wbc.castaway 0x00002554 _start + 0x158 (crt.c:272)
58 com.wbc.castaway 0x000023f8 start + 0x3c

Thread 1:
0 libSystem.B.dylib 0x900074c8 mach_msg_trap + 0x8
1 libSystem.B.dylib 0x90007018 mach_msg + 0x38
2 com.unsanity.ape 0xc000a954 __ape_internal + 0x90b8
3 com.unsanity.ape 0xc0001328 __ape_agent + 0x40
4 libSystem.B.dylib 0x900246e8 _pthread_body + 0x28

PPC Thread State:
srr0: 0x90a5c740 srr1: 0x0002f030 vrsave: 0x00000000
cr: 0x24000422 xer: 0x00000004 lr: 0x90a5c718 ctr: 0x9000a6c0
r0: 0x00000000 r1: 0xbfffd2a0 r2: 0xa09f04bc r3: 0xbfffce40
r4: 0x40000000 r5: 0x00000000 r6: 0xbfffcf80 r7: 0x00000004
r8: 0x00000003 r9: 0x00152e20 r10: 0x00000b0f r11: 0x24000422
r12: 0x9000a6c0 r13: 0x00000000 r14: 0x00000000 r15: 0xa2df47cc
r16: 0x0010e5b0 r17: 0xa2dfb274 r18: 0x00000000 r19: 0xa2dfb274
r20: 0xa09f71e8 r21: 0x00000177 r22: 0x00000000 r23: 0x00157bd0
r24: 0x00000000 r25: 0x00004284 r26: 0x00158770 r27: 0xa0a01b48
r28: 0x00000000 r29: 0xa09f5538 r30: 0x00000000 r31: 0x90a5c650

Binary Images Description:
0x1000 - 0x2fff com.wbc.castaway 1.0 (1.0b1) /Installers/Cast
Away.app/Contents/MacOS/Cast Away
0xc7000 - 0xe3fff com.unsanity.windowshadex.cocoa WindowShade X Cocoa
Bits version 3.1 (3.1) /Users/deege/Library/Application
Enhancers/WindowShade X.ape/Contents/PlugIns/WindowShade X Cocoa
Bits.ape/Contents/MacOS/WindowShade X Cocoa Bits
0x87fb0000 - 0x87ff3fff com.apple.AppleScriptKit 1.3.1 (38)
/System/Library/Frameworks/AppleScriptKit.framework/Versions/A/AppleScriptKi
t
0x8fe00000 - 0x8fe4ffff dyld /usr/lib/dyld
0x90000000 - 0x90122fff libSystem.B.dylib /usr/lib/libSystem.B.dylib
0x90190000 - 0x9023dfff com.apple.CoreFoundation 6.3.6 (299.33)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundatio
n
0x90280000 - 0x904f9fff com.apple.CoreServices.CarbonCore 10.3.6 (10.3.5)
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Carb
onCore.framework/Versions/A/CarbonCore
0x90570000 - 0x905dffff com.apple.framework.IOKit 1.3.6 (???)
/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
0x90610000 - 0x9069afff com.apple.CoreServices.OSServices 3.0.1
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSSe
rvices.framework/Versions/A/OSServices
0x90700000 - 0x90700fff com.apple.CoreServices 10.3 (???)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
0x90720000 - 0x90787fff com.apple.audio.CoreAudio 2.1.2
/System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
0x907f0000 - 0x907f9fff com.apple.DiskArbitration 2.0.4
/System/Library/PrivateFrameworks/DiskArbitration.framework/Versions/A/DiskA
rbitration
0x90810000 - 0x90810fff com.apple.ApplicationServices 1.0 (???)
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Applicat
ionServices
0x90830000 - 0x9089ffff libobjc.A.dylib /usr/lib/libobjc.A.dylib
0x90910000 - 0x90983fff com.apple.DesktopServices 1.2.3
/System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/D
esktopServicesPriv
0x909f0000 - 0x90b4bfff com.apple.Foundation 6.3.5 (500.56)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
0x90d00000 - 0x90d1bfff com.apple.SystemConfiguration 1.7.1 (???)
/System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemCo
nfiguration
0x90d40000 - 0x90d40fff com.apple.Carbon 10.3 (???)
/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
0x90ec0000 - 0x90ec0fff com.apple.Cocoa 6.3 (???)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
0x910b0000 - 0x91101fff com.apple.bom 1.2.5 (63.2)
/System/Library/PrivateFrameworks/Bom.framework/Versions/A/Bom
0x912a0000 - 0x912bdfff com.apple.audio.SoundManager 3.8
/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CarbonSoun
d.framework/Versions/A/CarbonSound
0x912e0000 - 0x912f7fff com.apple.LangAnalysis 1.5.4
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Framewor
ks/LangAnalysis.framework/Versions/A/LangAnalysis
0x91320000 - 0x913dffff ColorSync
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Framewor
ks/ColorSync.framework/Versions/A/ColorSync
0x91460000 - 0x91473fff com.apple.speech.synthesis.framework 3.2
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Framewor
ks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis
0x914a0000 - 0x91509fff com.apple.htmlrendering 1.1.2
/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HTMLRender
ing.framework/Versions/A/HTMLRendering
0x91560000 - 0x91619fff com.apple.QD 3.4.65 (???)
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Framewor
ks/QD.framework/Versions/A/QD
0x91670000 - 0x916a8fff com.apple.AE 1.4
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Framewor
ks/AE.framework/Versions/A/AE
0x916e0000 - 0x91773fff com.apple.print.framework.PrintCore 3.3
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Framewor
ks/PrintCore.framework/Versions/A/PrintCore
0x917e0000 - 0x917f0fff com.apple.speech.recognition.framework 3.3
/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SpeechReco
gnition.framework/Versions/A/SpeechRecognition
0x91810000 - 0x9182afff com.apple.openscripting 1.2.1 (???)
/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScript
ing.framework/Versions/A/OpenScripting
0x91850000 - 0x91860fff com.apple.ImageCapture 2.1.5
/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCaptu
re.framework/Versions/A/ImageCapture
0x91890000 - 0x9189cfff com.apple.help 1.0.1
/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.frame
work/Versions/A/Help
0x918c0000 - 0x918cdfff com.apple.CommonPanels 1.2.1 (1.0)
/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPane
ls.framework/Versions/A/CommonPanels
0x918f0000 - 0x9193efff com.apple.print.framework.Print 3.3
/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.fram
ework/Versions/A/Print
0x91990000 - 0x9199bfff com.apple.securityhi 1.2 (90)
/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI
framework/Versions/A/SecurityHI
0x919c0000 - 0x91a33fff com.apple.NavigationServices 3.3.2
/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Navigation
Services.framework/Versions/A/NavigationServices
0x91a90000 - 0x91a90fff com.apple.audio.units.AudioUnit 1.3.2
/System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit
0x91ab0000 - 0x91ac4fff libCGATS.A.dylib
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Framewor
ks/CoreGraphics.framework/Versions/A/Resources/libCGATS.A.dylib
0x91ae0000 - 0x91aebfff libCSync.A.dylib
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Framewor
ks/CoreGraphics.framework/Versions/A/Resources/libCSync.A.dylib
0x91b10000 - 0x91b2afff libPDFRIP.A.dylib
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Framewor
ks/CoreGraphics.framework/Versions/A/Resources/libPDFRIP.A.dylib
0x91b50000 - 0x91b5ffff libPSRIP.A.dylib
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Framewor
ks/CoreGraphics.framework/Versions/A/Resources/libPSRIP.A.dylib
0x91b80000 - 0x91b93fff libRIP.A.dylib
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Framewor
ks/CoreGraphics.framework/Versions/A/Resources/libRIP.A.dylib
0x92070000 - 0x92096fff com.apple.FindByContent 1.4 (1.2)
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Framewor
ks/FindByContent.framework/Versions/A/FindByContent
0x920c0000 - 0x922a7fff com.apple.security 2.4 (177)
/System/Library/Frameworks/Security.framework/Versions/A/Security
0x92430000 - 0x92468fff com.apple.LaunchServices 10.3.5 (98.4)
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Framewor
ks/LaunchServices.framework/Versions/A/LaunchServices
0x92740000 - 0x92777fff com.apple.CFNetwork 1.2.1 (7)
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CFNe
twork.framework/Versions/A/CFNetwork
0x927d0000 - 0x92b54fff com.apple.HIToolbox 1.3.5 (???)
/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.
framework/Versions/A/HIToolbox
0x92d30000 - 0x92d80fff com.apple.HIServices 1.4.1 (0.0.1d1)
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Framewor
ks/HIServices.framework/Versions/A/HIServices
0x92dc0000 - 0x932bffff com.apple.AppKit 6.3.6 (743.33)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
0x935d0000 - 0x938a8fff com.apple.CoreGraphics 1.203.30 (???)
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Framewor
ks/CoreGraphics.framework/Versions/A/CoreGraphics
0x939a0000 - 0x939b4fff libcups.2.dylib /usr/lib/libcups.2.dylib
0x939d0000 - 0x939d4fff libmathCommon.A.dylib
/usr/lib/system/libmathCommon.A.dylib
0x93b50000 - 0x93bf3fff com.apple.audio.toolbox.AudioToolbox 1.3.2
/System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
0x94060000 - 0x94078fff com.apple.WebServices 1.1.1 (1.1.0)
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/WebS
ervicesCore.framework/Versions/A/WebServicesCore
0x945b0000 - 0x945b9fff libz.1.dylib /usr/lib/libz.1.dylib
0x94610000 - 0x9462afff libresolv.9.dylib /usr/lib/libresolv.9.dylib
0x94650000 - 0x946affff com.apple.SearchKit 1.0.2
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Sear
chKit.framework/Versions/A/SearchKit
0x94a30000 - 0x94af5fff libxml2.2.dylib /usr/lib/libxml2.2.dylib
0x94b20000 - 0x94badfff com.apple.ink.framework 101.1.3 (55.10)
/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framew
ork/Versions/A/Ink
0x968d0000 - 0x969b2fff libicucore.A.dylib /usr/lib/libicucore.A.dylib
0x96a20000 - 0x96ae2fff libcrypto.0.9.7.dylib
/usr/lib/libcrypto.0.9.7.dylib
0x96b40000 - 0x96b6efff libssl.0.9.7.dylib /usr/lib/libssl.0.9.7.dylib
0x96bf0000 - 0x96c7ffff ATS
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Framewor
ks/ATS.framework/Versions/A/ATS
0x96cb0000 - 0x96d9efff libiconv.2.dylib /usr/lib/libiconv.2.dylib
0x97510000 - 0x97518fff libbsm.dylib /usr/lib/libbsm.dylib
0xc0000000 - 0xc000efff com.unsanity.ape 1.4.1
/Library/Frameworks/ApplicationEnhancer.framework/Versions/A/ApplicationEnha
ncer

With jon’s help, I determined that the problem was the use of the date picker, which is tiger only.

You’d think that apple would have built in ignores for objects it doesn’t know about, so apps won’t simply crash.

anyway, to answer part of my original question, you can do a compatibility check in interface builder, that’s a good first start.

now my issue is whether it is possible to:

a) create a date picker on the fly (see dynamic object thread)

or

b) load a different nib file depending on the system version (ie that would involve no nib loading until the script says to load one)

Yes, you need to take the main window out of the MainMenu.nib (you still need this nib for the menu, of course). The easiest way to do this is to open the MainMenu.nib and do a save as. Call the new nib MainWindow104.nib and make sure it is added to your project. In this new nib, remove the main menu and any other window or object other than the main window that may be in the nib. Save this nib. Now, with this nib, do another save as and call it MainWindow103.nib and, again, add it to your project. In this nib, delete the NSDatePicker and any other object that isn’t 10.3.x compatible. Save and close. Finally, open the original MainMenu.nib again and remove the main window object. Save and close.

Now you should have three nibs: MainMenu.nib which includes your main menu and other common windows such as a custom about window, etc.; MainWindow104.nib which just includes the main window including 10.4-only objects; and MainWindow103.nib that contains the same main window without any incompatible objects. In your code, early on, say in the “will finish launching” handler, check for the system version and then load the appropriate nib:

on will finish launching the_object
	set MacOS_version to (my gestalt_version_info("sysv", 4))
	if MacOS_version < "10.4" then
		load nib "MainWindow103"
	else
		load nib "MainWindow104"
	end if
end will finish launching

on gestalt_version_info(gestalt_code, string_length)
	try
		set {gc1, gc2, gc3, gc4} to (my num_to_hex((system attribute gestalt_code), string_length))
		if gc1 = "0" then set a to ""
		return ("" & {gc1, gc2, ".", gc3, ".", gc4}) as Unicode text
	on error
		return "unknown"
	end try
end gestalt_version_info

on num_to_hex(hex_data, string_length)
	set hex_string to {}
	repeat with i from string_length to 1 by -1
		set hex_string to ((hex_data mod 16) as Unicode text) & hex_string
		set hex_data to hex_data div 16
	end repeat
	return "" & hex_string
end num_to_hex

Jon

thanks jon,

i continue (resolve?) this on this other thread:

http://bbs.applescript.net/viewtopic.php?id=13454