Errors Exiting SDL on Windows

I am writing a cross-platform SDL app which
will run on OS X and Windows. The app was
writen nativly on OS X and the code was
ported to Windows.
I am having one problem with the Windows version.
When ever the program tries to exit
after de-initalizing the three libraries i use
(SDL, SDL_mixer and SDL_ttf) the program crashes.
The error is a write access violation. HELP PLEASE!!

what order are you deinitializing them in?> ----- Original Message -----

From: jjack@hightechhigh.org (Jonathan Jack)
To:
Sent: Thursday, August 26, 2004 11:47 AM
Subject: [SDL] Errors Exiting SDL on Windows

I am writing a cross-platform SDL app which
will run on OS X and Windows. The app was
writen nativly on OS X and the code was
ported to Windows.
I am having one problem with the Windows version.
When ever the program tries to exit
after de-initalizing the three libraries i use
(SDL, SDL_mixer and SDL_ttf) the program crashes.
The error is a write access violation. HELP PLEASE!!


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I am de-initializing them in this order:
SDL_mixer, SDL_ttf, SDLOn Aug 26, 2004, at 12:15 PM, Alan Wolfe wrote:

what order are you deinitializing them in?

----- Original Message -----
From: “jjack” <@Jonathan_Jack>
To:
Sent: Thursday, August 26, 2004 11:47 AM
Subject: [SDL] Errors Exiting SDL on Windows

I am writing a cross-platform SDL app which
will run on OS X and Windows. The app was
writen nativly on OS X and the code was
ported to Windows.
I am having one problem with the Windows version.
When ever the program tries to exit
after de-initalizing the three libraries i use
(SDL, SDL_mixer and SDL_ttf) the program crashes.
The error is a write access violation. HELP PLEASE!!


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I have used the debugger and it says the program errors out on the
function i use to handle mouse input and movement. It says that it
can’t write the parameters (int x, int y). But then on the other hand
when I use printf() to see how far the program gets it says it
de-initializes all the libraries, and it appears to error out when to
program tries to use exit()On Aug 27, 2004, at 2:11 AM, Donny Viszneki wrote:

Well, first, you should have sent this to the list, and not just to
me, but I don’t mind.

Second, you really didn’t include any more information here than was
in your first email.

Third, let me just take a shot in the dark here: perhaps you are
uninitializing a certain library both manually and using atexit() or
onexit(). For instance, if in an early version of your code, as many
beginners do, you began with some example code. The example code might
have been using atexit, and you later chose to go without atexit, but
forgot to remove the atexit code. Why don’t you search your code for
the string “atexit” and also “onexit” and see if that’s the problem.

If it’s not, might I recommend using a debugger rather than printf?
Beyond that, maybe you want to post your code to the list.

Good luck

On Aug 26, 2004, at 4:12 PM, Jonathan Jack wrote:

ok…

I am writing an app using SDL, SDL_mixer, SDL_image and SDL_ttf. I am
using SDL to handle mouse and keyboard events, SDL_image to deal with
drawing the interface, and SDL_ttf to render and display fonts on the
screen.

I have written several functions to interface with SDL_image,
SDL_mixer and SDL_ttf and simplify the process of loading a surface,
drawing it to the screen and updating the screen.

The problem I am having is this: after de-initializing SDL, SDL_mixer
and SDL_ttf my program crashes (on Windows only, not OS X) I know the
libraries de-initialize fine. I have done a printf() test to see how
far the program gets before it crashes, and after the libraries
de-initialize and (I’m assuming) the program tries to exit, it
crashes.

This is frustrating since the app runs fine on OS X (no problems what
so ever) and yet on Windows, it dies when someone tries to exit

On Aug 26, 2004, at 12:51 PM, Donny Viszneki wrote:

You’re going to have to be more specific about your program. I mean
based on the information you’ve given us, only if it was a known
problem with SDL would we be able to help you. So many people here
assume the problem isn’t their fault. And it always is…

On Aug 26, 2004, at 2:47 PM, jjack wrote:

I am writing a cross-platform SDL app which
will run on OS X and Windows. The app was
writen nativly on OS X and the code was
ported to Windows.
I am having one problem with the Windows version.
When ever the program tries to exit
after de-initalizing the three libraries i use
(SDL, SDL_mixer and SDL_ttf) the program crashes.
The error is a write access violation. HELP PLEASE!!


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

It really sounds to me like you’ve made some sort of mistake along the
way. If you’d like someone on the list to assist you perhaps you should
post your code.On Aug 27, 2004, at 11:34 AM, Jonathan Jack wrote:

I have used the debugger and it says the program errors out on the
function i use to handle mouse input and movement. It says that it
can’t write the parameters (int x, int y). But then on the other hand
when I use printf() to see how far the program gets it says it
de-initializes all the libraries, and it appears to error out when to
program tries to use exit()

On Aug 27, 2004, at 2:11 AM, Donny Viszneki wrote:

Well, first, you should have sent this to the list, and not just to
me, but I don’t mind.

Second, you really didn’t include any more information here than was
in your first email.

Third, let me just take a shot in the dark here: perhaps you are
uninitializing a certain library both manually and using atexit() or
onexit(). For instance, if in an early version of your code, as many
beginners do, you began with some example code. The example code
might have been using atexit, and you later chose to go without
atexit, but forgot to remove the atexit code. Why don’t you search
your code for the string “atexit” and also “onexit” and see if that’s
the problem.

If it’s not, might I recommend using a debugger rather than printf?
Beyond that, maybe you want to post your code to the list.

Good luck

On Aug 26, 2004, at 4:12 PM, Jonathan Jack wrote:

ok…

I am writing an app using SDL, SDL_mixer, SDL_image and SDL_ttf. I
am using SDL to handle mouse and keyboard events, SDL_image to deal
with drawing the interface, and SDL_ttf to render and display fonts
on the screen.

I have written several functions to interface with SDL_image,
SDL_mixer and SDL_ttf and simplify the process of loading a surface,
drawing it to the screen and updating the screen.

The problem I am having is this: after de-initializing SDL,
SDL_mixer and SDL_ttf my program crashes (on Windows only, not OS X)
I know the libraries de-initialize fine. I have done a printf() test
to see how far the program gets before it crashes, and after the
libraries de-initialize and (I’m assuming) the program tries to
exit, it crashes.

This is frustrating since the app runs fine on OS X (no problems
what so ever) and yet on Windows, it dies when someone tries to exit

On Aug 26, 2004, at 12:51 PM, Donny Viszneki wrote:

You’re going to have to be more specific about your program. I mean
based on the information you’ve given us, only if it was a known
problem with SDL would we be able to help you. So many people here
assume the problem isn’t their fault. And it always is…

On Aug 26, 2004, at 2:47 PM, jjack wrote:

I am writing a cross-platform SDL app which
will run on OS X and Windows. The app was
writen nativly on OS X and the code was
ported to Windows.
I am having one problem with the Windows version.
When ever the program tries to exit
after de-initalizing the three libraries i use
(SDL, SDL_mixer and SDL_ttf) the program crashes.
The error is a write access violation. HELP PLEASE!!


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

HOw much of the code do you want to see?On Aug 27, 2004, at 4:41 PM, Donny Viszneki wrote:

It really sounds to me like you’ve made some sort of mistake along the
way. If you’d like someone on the list to assist you perhaps you
should post your code.

On Aug 27, 2004, at 11:34 AM, Jonathan Jack wrote:

I have used the debugger and it says the program errors out on the
function i use to handle mouse input and movement. It says that it
can’t write the parameters (int x, int y). But then on the other hand
when I use printf() to see how far the program gets it says it
de-initializes all the libraries, and it appears to error out when to
program tries to use exit()

On Aug 27, 2004, at 2:11 AM, Donny Viszneki wrote:

Well, first, you should have sent this to the list, and not just to
me, but I don’t mind.

Second, you really didn’t include any more information here than was
in your first email.

Third, let me just take a shot in the dark here: perhaps you are
uninitializing a certain library both manually and using atexit() or
onexit(). For instance, if in an early version of your code, as many
beginners do, you began with some example code. The example code
might have been using atexit, and you later chose to go without
atexit, but forgot to remove the atexit code. Why don’t you search
your code for the string “atexit” and also “onexit” and see if
that’s the problem.

If it’s not, might I recommend using a debugger rather than printf?
Beyond that, maybe you want to post your code to the list.

Good luck

On Aug 26, 2004, at 4:12 PM, Jonathan Jack wrote:

ok…

I am writing an app using SDL, SDL_mixer, SDL_image and SDL_ttf. I
am using SDL to handle mouse and keyboard events, SDL_image to deal
with drawing the interface, and SDL_ttf to render and display fonts
on the screen.

I have written several functions to interface with SDL_image,
SDL_mixer and SDL_ttf and simplify the process of loading a
surface, drawing it to the screen and updating the screen.

The problem I am having is this: after de-initializing SDL,
SDL_mixer and SDL_ttf my program crashes (on Windows only, not OS
X) I know the libraries de-initialize fine. I have done a printf()
test to see how far the program gets before it crashes, and after
the libraries de-initialize and (I’m assuming) the program tries to
exit, it crashes.

This is frustrating since the app runs fine on OS X (no problems
what so ever) and yet on Windows, it dies when someone tries to
exit

On Aug 26, 2004, at 12:51 PM, Donny Viszneki wrote:

You’re going to have to be more specific about your program. I
mean based on the information you’ve given us, only if it was a
known problem with SDL would we be able to help you. So many
people here assume the problem isn’t their fault. And it always
is…

On Aug 26, 2004, at 2:47 PM, jjack wrote:

I am writing a cross-platform SDL app which
will run on OS X and Windows. The app was
writen nativly on OS X and the code was
ported to Windows.
I am having one problem with the Windows version.
When ever the program tries to exit
after de-initalizing the three libraries i use
(SDL, SDL_mixer and SDL_ttf) the program crashes.
The error is a write access violation. HELP PLEASE!!


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Jonathan Jack wrote:

HOw much of the code do you want to see?

Enough code that :

  • compiles as-is
  • reproduces your problem
    (Of course you can remove parts that are irrelevant to your problem).

Stephane

I solved my problem, the problem was that i was using Microsoft Visual
Studio.NET and a tutorial i read said to choose a Win32 Windows
Application and not a Win32 Console Application.On Aug 28, 2004, at 4:56 AM, Stephane Marchesin wrote:

Jonathan Jack wrote:

HOw much of the code do you want to see?

Enough code that :

  • compiles as-is
  • reproduces your problem
    (Of course you can remove parts that are irrelevant to your problem).

Stephane


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

It sounds a lot like a problem I was having a while back.
The exact problem was that somehow, atexit() was getting passed a NULL pointer
somewhere (thus why it crashes when exit() is called).
I never did find the exact cause of it; I spent nearly 2 months putting
breakpoints everwhere I could inside the SDL library itself, and also inside
the C standard library (Yeah, go 'ahead and try to recompile it a couple
hundred times).
But, I found that if I disabled the Parachute (SDL_Init(SDL_INIT_NO_PARACHUTE)
or something like that), the crash stopped hapening. Try that out.
If that doesn’t help, I’d sugest compiling your application with MinGW or
Cygwin – I never had that problem occur with either of those (though,
initially compiling the library can get kinda involved).