JACoders / OpenJK

Community effort to maintain and improve Jedi Academy (SP & MP) + Jedi Outcast (SP only) released by Raven Software
GNU General Public License v2.0
2.01k stars 612 forks source link

Windows Dedicated Server crashes upon CTRL+C or hitting the X #887

Closed eezstreet closed 6 years ago

eezstreet commented 7 years ago

It's not supposed to be a graceful kill, but it crashes while shutting down.

The problem seems to be happening because the signal handler for Windows runs on a separate thread from the main thread, and orders the game to terminate while it's in the middle of a gamecode frame.

ensiform commented 7 years ago

Test further upstream.

What did you do to verify its "crashing inappropriately" ?

eezstreet commented 7 years ago

All I did was close it via Ctrl+C and via X button and it crashed in both cases without further modifications.

dionrhys commented 7 years ago

OpenJK behaviour deviates from ioq3. ioq3 uses the signal() functions on all platforms, whereas OpenJK uses signal() for unix but SetConsoleCtrlHandler for Windows.

signal() on Linux interrupts applications by hijacking the "root" thread (and I believe other threads can keep running?)

Windows control handlers spawn a new thread each time, so this is problematic when there's no synchronization in place. signal() interrupts processes on Windows like it does on Unix, except if the signal is a Ctrl+C... (or is there some distinction here between GUI Win32 apps and console apps?)

Hopefully just using signal() everywhere like ioq3 does would work? Can imagine there still being synchronization issues though.

ensiform commented 7 years ago

ioquake3 still uses SetConsoleCtrlHandler, wtf you smokin.

https://github.com/ioquake/ioq3/blob/master/code/sys/con_win32.c#L294

The only difference is we never setup the select few common shared signals. Doing so makes it semi-gracefully exit on seg faults though. No notice etc.

Windows does this extra thread thing regardless of setting that from what I have read before.

AlexCS1337 commented 7 years ago

Th

AlexCS1337 commented 7 years ago

This was fixed wasnt it?

ensiform commented 7 years ago

Not really but it's not really an issue either.

AlexCS1337 commented 7 years ago

Doesn't seem to happen anymore for me I think

xycaleth commented 6 years ago

I'll close this then if we don't think it's a problem anymore