The Castle Doctrine Forums

Discuss the massively-multiplayer home defense game.

You are not logged in.

#1 2013-06-27 07:07:53

jasonrohrer
Administrator
Registered: 2013-04-01
Posts: 1,231

Anyone ever seen freezing on exit?

Back in April, I got a report from someone on Windows 7 who saw the game freezing consistently on exit.  They would then need to force-kill it to exit the game.

We traced this down to SDL_CloseAudio hanging.  Not sure why.

So, I tried inserting SDL_LockAudio in front of the SDL_CloseAudio call.  Unfortunately, I never heard back from this person about whether this fix worked.

BUT.... the fix has been in the main source tree ever since, working its way into v6, v7, v8, and v9.

Now... occasionally on Linux, *I* am seeing hangs on exit, and can trace it to SDL_CloseAudio.  But I don't recall this ever happening for my other games that use the same code, so I think that having the Lock in there is actually causing a new problem for me.  And the sample code that ships with SDL does not lock before closing the audio.  Thus, I'm thinking about reverting it.

So... is anyone here using Windows 7?  Did you ever see v5 freeze there on exit?  What about later versions?

Offline

#2 2013-06-27 08:17:45

ukuko
Member
Registered: 2013-04-06
Posts: 333

Re: Anyone ever seen freezing on exit?

Uh v5 used to crash on Windows 7 every time I opened it (on a really shoddy laptop, mind you). Versions since have been okay.

Offline

#3 2013-06-27 08:27:51

zed
Member
Registered: 2013-04-16
Posts: 161

Re: Anyone ever seen freezing on exit?

I've seen occasional hangs on exit, requiring a kill -9.

I'm not sure, but I think in my case it might be triggered by switching to the console immediately after hitting '%'. I can try to track it down further if you like.

Offline

#4 2013-06-27 10:05:31

jasonrohrer
Administrator
Registered: 2013-04-01
Posts: 1,231

Re: Anyone ever seen freezing on exit?

Well, I think the "fix" that I put in place for that one player (who never wrote back to tell me if the fix actually worked) was causing some of these more recent hangs. 

I can see how locking the audio before closing the audio can cause a deadlock (because CloseAudio waits for the audio thread, which might be blocked on the lock that you just locked before calling CloseAudio).  Of course, this would only deadlock if the audio thread happened to run right between the lock call and the CloseAudio call, which is why it rarely happens.

Anyway, removing that lock for v10.  Should fix the occasional hangs

Offline

#5 2013-06-29 07:15:25

zed
Member
Registered: 2013-04-16
Posts: 161

Re: Anyone ever seen freezing on exit?

Just got another freeze after hitting '%' to exit. I didn't do anything weird.

I tried to use strace to see what was going on - it looks like it was some sort of lock. 32506 was the main cd process.

$ strace -p 32506
Process 32506 attached - interrupt to quit
futex(0xb5ba3ba8, FUTEX_WAIT, 32513, NULL^C <unfinished ...>
Process 32506 detached
>0<1{10:05:39}~/src/hackings/cd$ strace -p 32513
Process 32513 attached - interrupt to quit
futex(0x8443460, FUTEX_WAIT_PRIVATE, 2, NULL^C <unfinished ...>
Process 32513 detached

I'll try to run the game in gdb from now on, see if I can catch it again.

Offline

#6 2013-06-29 18:38:52

jasonrohrer
Administrator
Registered: 2013-04-01
Posts: 1,231

Re: Anyone ever seen freezing on exit?

I've found that I can attach GDB to a running process and get a full trace.

I'm not using any mutexes in my own code, so it sounds like this is another SDL audio thing.... man, I thought I fixed it!

Yeah, if you could catch it in GDB, that would be greatly helpful.

Offline

Board footer

Powered by FluxBB 1.5.8