dhewm/dhewm3

Freeze on Mac OS X 10.5 PowerPC

Betonmischer86 opened this issue · 3 comments

After a few minutes of playing (either interacting with the game or standing still) the game would freeze every time. Built from the latest source with the debug flag and libbacktrace support (thanks to your suggestion on how to make libbacktrace work in #568). The system (4xPPC G5, 16 GB of RAM, Quadro FX 4500) is rock solid in other games (e.g. Prey). Here's the gdb output.

(gdb) thread apply all backtrace

Thread 7 (process 19912 thread 0xbf03):
#0  0x92391a8c in __semwait_signal ()
#1  0x923ce31c in _pthread_cond_wait ()
#2  0x9133fb6c in glvmDoWork ()
#3  0x923ccf74 in _pthread_start ()

Thread 6 (process 19912 thread 0xb803):
#0  0x9238b0f8 in semaphore_timedwait_signal_trap ()
#1  0x923ce218 in _pthread_cond_wait ()
#2  0x9255e784 in CAGuard::WaitFor ()
#3  0x9255e9f4 in HP_IOThread::WorkLoop ()
#4  0x9255e7f4 in HP_IOThread::ThreadEntry ()
#5  0x9254cde8 in CAPThread::Entry ()
#6  0x923ccf74 in _pthread_start ()

Thread 5 (process 19912 thread 0xb303):
#0  0x9238b078 in mach_msg_trap ()
#1  0x92391fa0 in mach_msg ()
#2  0x90732398 in CFRunLoopRunSpecific ()
#3  0x9254cfac in HALRunLoop::OwnThread ()
#4  0x9254cde8 in CAPThread::Entry ()
#5  0x923ccf74 in _pthread_start ()

Thread 4 (process 19912 thread 0x5807):
#0  0x92391a8c in __semwait_signal ()
#1  0x923ce31c in _pthread_cond_wait ()
#2  0x0291e2f0 in SDL_CondWait_REAL ()
#3  0x0030025c in Sys_WaitForEvent (index=0) at /Users/vkosikhin/git/dhewm3/neo/sys/threads.cpp:207
#4  0x00177e44 in BackgroundDownloadThread (pexit=0x6023b0) at /Users/vkosikhin/git/dhewm3/neo/framework/FileSystem.cpp:3432
#5  0x028df1f8 in SDL_RunThread ()
#6  0x0291dd18 in RunThread ()
#7  0x923ccf74 in _pthread_start ()

Thread 3 (process 19912 thread 0x4103):
#0  0x92391a8c in __semwait_signal ()
#1  0x923ce31c in _pthread_cond_wait ()
#2  0x0291e3dc in SDL_CondWaitTimeout_REAL ()
#3  0x0291df00 in SDL_SemWaitTimeout_REAL ()
#4  0x028dfd30 in SDL_TimerThread ()
#5  0x028df1f8 in SDL_RunThread ()
#6  0x0291dd18 in RunThread ()
#7  0x923ccf74 in _pthread_start ()

Thread 2 (process 19912 thread 0x2603):
#0  0x9238b078 in mach_msg_trap ()
#1  0x92391fa0 in mach_msg ()
#2  0x05a805a0 in __ape_agent ()
#3  0x923ccf74 in _pthread_start ()

Thread 1 (process 19912 local thread 0x2e03):
#0  0x92391a88 in __semwait_signal ()
#1  0x923ce31c in _pthread_cond_wait ()
#2  0x0291e2f0 in SDL_CondWait_REAL ()
#3  0x0030025c in Sys_WaitForEvent (index=1) at /Users/vkosikhin/git/dhewm3/neo/sys/threads.cpp:207
#4  0x001a2094 in idSessionLocal::Frame (this=0x602dfc) at /Users/vkosikhin/git/dhewm3/neo/framework/Session.cpp:2721
#5  0x0012a234 in idCommonLocal::Frame (this=0x5ffbb0) at /Users/vkosikhin/git/dhewm3/neo/framework/Common.cpp:2439
#6  0x0030f1a8 in SDL_main (argc=4, argv=0x5b09a00) at /Users/vkosikhin/git/dhewm3/neo/sys/osx/DOOMController.mm:219
#7  0x00310320 in -[SDLMain applicationDidFinishLaunching:] (self=0x5b205a0, _cmd=0x91be96e0, note=0x5b12260) at /Users/vkosikhin/git/dhewm3/neo/sys/osx/SDLMain.m:313
#8  0x0361f688 in _nsnote_callback ()
#9  0x9071443c in _CFXNotificationPostNotification ()
#10 0x0361cdc4 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#11 0x02a31858 in -[NSApplication _postDidFinishNotification] ()
#12 0x02a31770 in -[NSApplication _sendFinishLaunchingNotification] ()
#13 0x029b9114 in -[NSApplication(NSAppleEventHandling) _handleAEOpen:] ()
#14 0x029b894c in -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] ()
#15 0x03640008 in -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] ()
#16 0x0363fddc in _NSAppleEventManagerGenericHandler ()
#17 0x03de0ce4 in aeDispatchAppleEvent ()
#18 0x03de0bec in dispatchEventAndSendReply ()
#19 0x03de09f0 in aeProcessAppleEvent ()
#20 0x04eb5410 in AEProcessAppleEvent ()
#21 0x029b6478 in _DPSNextEvent ()
#22 0x029b5c00 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#23 0x029af8a0 in -[NSApplication run] ()
#24 0x00310070 in CustomApplicationMain (argc=4, argv=0xbffff874) at /Users/vkosikhin/git/dhewm3/neo/sys/osx/SDLMain.m:240
#25 0x00310698 in main (argc=4, argv=0xbffff874) at /Users/vkosikhin/git/dhewm3/neo/sys/osx/SDLMain.m:390

I have no idea about this (and can't reproduce it because I don't own such hardware) - but maybe @SiliconExarch does, she contributed some Mac PPC fixes in the past (like #412)?

I figured the freeze was SDL-related, so I rebuilt with SDL 1.2.15 instead of 2.0.3, and the game has been stable so far. Still, it'd be great if @SiliconExarch or someone else has the means to get to the root cause of the issue and make SDL2 work, as it is the default version dhewm3 expects and you have to pass a cmake flag to use SDL 1. I'm willing to help with testing however I can.

Yeah, from the backtraces it looks possible that the main thread is frozen because it waits for AsyncTimer() (from neo/framework/Common.cpp) to call Sys_TriggerEvent(TRIGGER_EVENT_ONE);.

And AsyncTimer is called every 16ms from an SDL timer thread (SDL_AddTimer(USERCMD_MSEC, AsyncTimer, NULL);)

But I have no idea why that SDL timer thread (I think it's "Thread 3" in your backtrace) should itself freeze (or stop calling Sys_TriggerEvent() at least).
Of course it kinda sucks that on OSX PPC you're stuck with SDL 2.0.3, which at this point is about as ancient as 1.2.15 :-/