Read-only archive of the Armageddon Games Forums Archive (2000–2026) · About this archive

[OSX] Hey guys, the Mac Tile Paste Crash bug is still here

10 replies · 2,970 views · Started 27 August 2006

If you're using Mac 12d, and you paste a copied tile, ZQuest crashes.

Here's what the crash log says:

Date/Time:  2006-08-27 13:21:17 +1000
OS Version: 10.2.8 (Build 6R73)
Host: eMac.local.

Command: ZQuest Editor
PID: 5031

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

Thread 0:
#0 0x90006a28 in clock_sleep_trap
#1 0x9000672c in nanosleep
#2 0x9003e248 in usleep
#3 0x0017164c in -[AllegroAppDelegate applicationDidFinishLaunching:]
#4 0x97dfab40 in _nsNotificationCenterCallBack
#5 0x9016847c in _postNotification
#6 0x90165b90 in _CFNotificationCenterPostLocalNotification
#7 0x9318b16c in -[NSApplication _sendFinishLaunchingNotification]
#8 0x93161f98 in _requiredAEEventHandler
#9 0x91b56570 in aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned long, unsigned char*)
#10 0x91b590cc in dispatchEventAndSendReply(AEDesc const*, AEDesc*)
#11 0x91b56478 in aeProcessAppleEvent
#12 0x96a83778 in AEProcessAppleEvent
#13 0x9308e698 in _DPSNextEvent
#14 0x930a0824 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
#15 0x930b23f4 in -[NSApplication run]
#16 0x00171a78 in main
#17 0x000022b0 in _start (crt.c:272)
#18 0x00002158 in start

Thread 1 Crashed:
#0 0x000f40a8 in copy_tiles_united(int&, int&, int&, int&, bool, bool) (crt.c:355)
#1 0x000fbe88 in copy_tiles(int&, int&, int&, int&, bool, bool) (crt.c:355)
#2 0x00101524 in select_tile(int&, int&, int, int&, bool, int) (crt.c:355)
#3 0x0010164c in onTiles() (crt.c:355)
#4 0x00049678 in jwin_do_menu(MENU*, MENU_INFO*, int, int, int, int, int*, int, int) (crt.c:355)
#5 0x00049a38 in jwin_menu_proc (crt.c:355)
#6 0x0014dee8 in d_nbmenu_proc(int, DIALOG*, int) (crt.c:355)
#7 0x300326a8 in object_message
#8 0x30033e70 in update_dialog
#9 0x0014cdb4 in mangled_main(int, char**) (crt.c:355)
#10 0x00171744 in call_user_main
#11 0x00171784 in +[AllegroAppDelegate app_main:]
#12 0x97e2cc38 in forkThreadForFunction
#13 0x90020c28 in _pthread_body

Thread 2:
#0 0x9002568c in select
#1 0x300a89fc in ptimer_thread_func
#2 0x90020c28 in _pthread_body

Thread 3:
#0 0x90073ba8 in mach_msg_trap
#1 0x90005ed0 in mach_msg
#2 0x90148938 in __CFRunLoopRun
#3 0x90180f04 in CFRunLoopRunSpecific
#4 0x94652f80 in HALRunLoop::OwnThread(void*)
#5 0x946591e0 in CAPThread::Entry(CAPThread*)
#6 0x90020c28 in _pthread_body

Thread 4:
#0 0x90042588 in semaphore_timedwait_signal_trap
#1 0x9003e7b4 in _pthread_cond_wait
#2 0x946444fc in CAGuard::WaitFor(unsigned long long)
#3 0x94644130 in CAGuard::WaitUntil(unsigned long long)
#4 0x94642b20 in HPIOThread::WorkLoop()
#5 0x9465919c in HPIOThread::ThreadEntry(HPIOThread*)
#6 0x946591e0 in CAPThread::Entry(CAPThread*)
#7 0x90020c28 in _pthread_body

PPC Thread State:
srr0: 0x000f40a8 srr1: 0x0000d930 vrsave: 0x00000000
xer: 0x00000000 lr: 0x000fbe88 ctr: 0x001014f4 mq: 0x00000000
r0: 0xfffaec70 r1: 0xf002f5d0 r2: 0x300c9d2c r3: 0x00bd5298
r4: 0xf002f698 r5: 0xf002f694 r6: 0xf002f69c r7: 0x00000000
r8: 0x00000000 r9: 0xf002f69c r10: 0x30050b60 r11: 0x300b70f0
r12: 0x30050b58 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: 0x04f11fd0
r28: 0x000000ce r29: 0x0094d1d0 r30: 0xf002f5d0 r31: 0x000fbe04

GDB returns the following evidence:

Program received signal EXC_BAD_ACCESS, Could not access memory.
[Switching to process 14628 thread 0x1303]
0x00117624 in copy_tiles_united(int&, int&, int&, int&, bool, bool) (tile=@0x0, tile2=@0x0, copy=@0x0, copycnt=@0x0, rect=false, move=false) at zq_tiles.cpp:4437
4437 {
Developers, why exactly would this occur only on OSX?

Heap corruption, I'd say.

Unless you have a debugger that will tell you a more useful line number, the easiest is probably to systematically subdivide to find the problem. Start by commenting out all of the tile overwrite checks (lines 4657-5653) and see if it still crashes.

Recent progress!
I've found out that if I comment-out all of the code in copy_tiles_united that refer to this monstrous array:

bool move_combo_list[65280]
...then it starts working again.

Actually, I do believe it's the array definition itself that's causing the problem. I commented out everything below that line all the way down to just before "return true" and the crash still occured. But commenting out all of that plus the definition of move_combo_list suppresses the bug.

What if you change it to an array of ints and then initialize them all to 0, then change the references to the array from using true and false to using -1 and 0?

move_combo_list must not fit on the stack (which I suppose is not too surprising, given all the other stack-allocated huge arrays in that function).

I've heap-allocated these arrays instead; see if that fixes the problem.