Terminate not called after SDL_SetVideoMode()?

This is a somewhat strange bug. The following code works fine:

Code:

#include <SDL.h>
#include <windows.h>
#include

void term()
{
MessageBox(NULL, “Terminate”, “Debug”, MB_OK);
abort();
}

int SDL_main(int argc, char *argv[])
{
set_terminate(term);

SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);

throw (0);
SDL_SetVideoMode(800, 600, 0, SDL_OPENGL);

return (0);

}

However, in this version of the code term() is never called:

Code:

#include <SDL.h>
#include <windows.h>
#include

void term()
{
MessageBox(NULL, “Terminate”, “Debug”, MB_OK);
abort();
}

int SDL_main(int argc, char *argv[])
{
set_terminate(term);

SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);

SDL_SetVideoMode(800, 600, 0, SDL_OPENGL);
throw (0);

return (0);

}

The only difference between the two pieces of code is that in the broken one, I am throwing the exception after calling SDL_SetVideoMode() rather than before it. Another thing to note is that the second example works if I remove the SDL_OPENGL flag.

I am compiling with Microsoft Visual C++ 2005, I am using SDL version 1.2.15 although I have also tested it with version 1.2.14 and the problem still exists, and I am running it on Windows XP SP3 Home. My graphics card is an ATI Radeon X1300 PRO, and my computer completely supports up to OpenGL 2.1. I have the latest graphics card drivers.

I suspect the issue is related to passing the exception from C++ code to C code (SDL 1.2.15 is written in C, but my program is written in C++), but if possible I’d like to know exactly what is going wrong.------------------------
Blog: http://invisiblegdev.blogspot.com

**
This is a somewhat strange bug. The following code works fine:

Code:

#include **
#include **
#include **

void term()
{
MessageBox(NULL, “Terminate”, “Debug”, MB_OK);
abort();
}

int SDL_main(int argc, char *argv[])
{
set_terminate(term);

SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);

throw (0);
SDL_SetVideoMode(800, 600, 0, SDL_OPENGL);

return (0);
}

However, in this version of the code term() is never called:

Code:

#include **
#include **
#include **

void term()
{
MessageBox(NULL, “Terminate”, “Debug”, MB_OK);
abort();
}

int SDL_main(int argc, char *argv[])
{
set_terminate(term);

SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);

SDL_SetVideoMode(800, 600, 0, SDL_OPENGL);
throw (0);

return (0);
}

The only difference between the two pieces of code is that in the broken
one, I am throwing the exception after calling SDL_SetVideoMode() rather
than before it. Another thing to note is that the second example works if I
remove the SDL_OPENGL flag.

I am compiling with Microsoft Visual C++ 2005, I am using SDL version
1.2.15 although I have also tested it with version 1.2.14 and the problem
still exists, and I am running it on Windows XP SP3 Home. My graphics card
is an ATI Radeon X1300 PRO, and my computer completely supports up to
OpenGL 2.1. I have the latest graphics card drivers.

I suspect the issue is related to passing the exception from C++ code to C
code (SDL 1.2.15 is written in C, but my program is written in C++), but if
possible I’d like to know exactly what is going wrong.

I think the key is SDL_INIT_NOPARACHUTE. If I recall, that catches
exceptions and dies gracefully instead of with "XXXXXX has stopped worked"
message from Windows.On Sun, Jan 22, 2012 at 12:02 PM, InvisibleMan <invisible at ifthensoftware.net wrote:


Blog: http://invisiblegdev.blogspot.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I actually added that flag to try and fix the problem. The code doesn’t work with or without it.------------------------
Blog: http://invisiblegdev.blogspot.com