assert: Use TerminateProcess() on Windows, vs ExitProcess (thanks, Jack!).
authorRyan C. Gordon <icculus@icculus.org>
Wed, 28 Feb 2018 01:23:49 -0500
changeset 1190897092601ea78
parent 11907 4d9a8db6baf6
child 11909 b2e68bf41993
assert: Use TerminateProcess() on Windows, vs ExitProcess (thanks, Jack!).

"What I have done is use TerminateProcess rather than ExitProcess.
ExitProcess will cause Microsoft's leak detection to continue, TerminateProcess
won't. It is also technically wrong to use ExitProcess in the case of aborting
the application.

Jack Powell
Twitter @jack9267"
src/SDL_assert.c
     1.1 --- a/src/SDL_assert.c	Mon Feb 26 08:39:25 2018 -0800
     1.2 +++ b/src/SDL_assert.c	Wed Feb 28 01:23:49 2018 -0500
     1.3 @@ -123,7 +123,11 @@
     1.4  static SDL_NORETURN void SDL_ExitProcess(int exitcode)
     1.5  {
     1.6  #ifdef __WIN32__
     1.7 -    ExitProcess(exitcode);
     1.8 +    /* "if you do not know the state of all threads in your process, it is
     1.9 +       better to call TerminateProcess than ExitProcess"
    1.10 +       https://msdn.microsoft.com/en-us/library/windows/desktop/ms682658(v=vs.85).aspx */
    1.11 +    TerminateProcess(GetCurrentProcess(), exitcode);
    1.12 +
    1.13  #elif defined(__EMSCRIPTEN__)
    1.14      emscripten_cancel_main_loop();  /* this should "kill" the app. */
    1.15      emscripten_force_exit(exitcode);  /* this should "kill" the app. */