The Ur-Quan Masters Home Page Welcome, Guest. Please login or register.
Did you miss your activation email?
October 12, 2024, 08:40:21 pm
Home Help Search Login Register
News: Celebrating 30 years of Star Control 2 - The Ur-Quan Masters

+  The Ur-Quan Masters Discussion Forum
|-+  The Ur-Quan Masters Re-Release
| |-+  Technical Issues (Moderator: Death 999)
| | |-+  OS X "semaphore" lockup - ugly workaround
« previous next »
Pages: [1] Print
Author Topic: OS X "semaphore" lockup - ugly workaround  (Read 2847 times)
Foo von Bar
Guest


Email
OS X "semaphore" lockup - ugly workaround
« on: December 21, 2002, 08:37:32 am »

Well, I found a rather unpleasant workaround to the problem I posted here before about, i.e. UQM locking up with a message about semaphores -- but giving no stack backtrace or anything, even in debugging mode.

The workaround -- to disable the second processor on my dual-CPU G4! The very same compile of the very same current CVS version of UQM runs just fine on my system when booted with only a single CPU running. (However, UQM runs just fine on my dual-P3 Linux box in the office ....)

Now, that's a little bit extreme of a workaround, so I do hope this discovery can help those who actually know something about SMP and threading find what's wrong! Again, the problem occurs during what I'd call scene transitions, e.g. when loading the melee menu back up after a battle, or landing on a planet, or loading the starmap -- and is intermittent.

Incidentally, if there are any other Mac users here who don't know how to shut off the second CPU on a dual system, here's the trick: boot into Open Firmware (Cmd-Option-O-F) and enter "setenv boot-args cpus=1", then "boot". To turn the second CPU back on, go back into Open Firmware and "setenv boot-args cpus=2".
Logged
PhracturedBlue
Frungy champion
**
Offline Offline

Posts: 88


Me developer. Here me roar!


View Profile
Re: OS X "semaphore" lockup - ugly workaround
« Reply #1 on: December 21, 2002, 08:13:33 pm »

Exactly which semaphore message are you getting?
Logged
Foo von Bar
Guest


Email
Re: OS X "semaphore" lockup - ugly workaround
« Reply #2 on: December 22, 2002, 01:56:39 am »

Quote
Exactly which semaphore message are you getting?


Just prior to the crash:

WARNING: trying to clear a free semaphore (value=1)

And then, when hitting Ctrl-C to exit  the program (the ` key does not work):

WARNING: SetSemaphore did not return 0, this could be bad!
 
Logged
PhracturedBlue
Frungy champion
**
Offline Offline

Posts: 88


Me developer. Here me roar!


View Profile
Re: OS X "semaphore" lockup - ugly workaround
« Reply #3 on: December 22, 2002, 05:25:55 am »

Well I put that message there, and it should be harmless if you see it as the game loads (there is a problem with the clock semaphore initialization that causes it).  If  you see it at any other time, it is bad.  Assuming  you are compiling from source, go into libs/threads/thrcommon.c and in ClearSemaphore, comment out the 'return' right after that Warning message.  that will allow the semaphore to be double freed, and should cause a spew of identical warnings while in SolarSystem view.  If it stops the hang, that  would be VERY useful to know.

Logged
PhracturedBlue
Frungy champion
**
Offline Offline

Posts: 88


Me developer. Here me roar!


View Profile
Re: OS X "semaphore" lockup - ugly workaround
« Reply #4 on: December 22, 2002, 05:34:08 am »

Okay, I just reread your original post, and my previous message may not be of much use after all.  Do you have IRC access?  In general, I can add code to monitor all of the Semaphores,  and tell you which one failed (which would be very helpful), but it  is a non-trivial patch, and I'm not  sure I want to place it in CVS without getting it tested (and since I can't duplicate your problems, I can't test it too thoroughly).  If you cann't get on IRC, I can probably post a patch here for you to test, but it'd be easier in a more rapid-response environment.

By the way, for anyone interested, even though Semaphores can have values >1, in UQM they should only have values of 1 and 0.
Logged
PhracturedBlue
Frungy champion
**
Offline Offline

Posts: 88


Me developer. Here me roar!


View Profile
Re: OS X "semaphore" lockup - ugly workaround
« Reply #5 on: December 22, 2002, 06:26:40 pm »

Alright here you go:
http://phracturedblue.com/sc2/semcheck.diff

This patch should help you debug any semaphore locking issues.

It will basically spew out information about any possible probblems it sees with the semaphores (not everything that is reported is a problem though)  Hopefully it can help you determine  where the deadlock is.

note that  this patch will not go into CVS (at least in its current form), so use it at your own risk.  You'll need the latest CVS (as of 12/22) forit to patch in cleanly.
Logged
PhracturedBlue
Frungy champion
**
Offline Offline

Posts: 88


Me developer. Here me roar!


View Profile
Re: OS X "semaphore" lockup - ugly workaround
« Reply #6 on: December 23, 2002, 07:41:18 am »

Okay one more update.
CVS currently includes a modified version of the patch I posted earlier, and it should help.  There is also a deadlock debugger in the code (disabled by default).  Enable it by going into libs/threads/thrcommon.c and changing
#undef DEBUG_SEM_DEADLOCK
to
#define DEUG_SEM_DEADLOCK

This will turn on code that will report a message whenever a SemaphoreSet is blocked for more than 60 seconds.  You will get messages whenever you spend time in planet view, etc, but if your system seems to deadlock, it should print out a message after a minute telling you what is going on.

Logged
Foo von Bar
Guest


Email
Re: OS X "semaphore" lockup - ugly workaround
« Reply #7 on: December 25, 2002, 08:38:18 am »

Quote

This will turn on code that will report a message whenever a SemaphoreSet is blocked for more than 60 seconds.  You will get messages whenever you spend time in planet view, etc, but if your system seems to deadlock, it should print out a message after a minute telling you what is going on.


Well, I'm now running the current CVS build with two processors, and I am happy to say that I have not had a chance yet to use this debugger ... since it is not crashing. I am, I suppose, a *happy camper*. Thanks! If it does start crashing, I will show up again here *frumple* with a useful debug message.
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!