DGA mode sometimes kills X when freeing the screen

Perhaps one out of ten times that I run my program in DGA mode X will die
when SDL_Quit() is called.

By “X dies” I mean, I am returned to the console, except:

  1. The console only occupies the top 1/5 of the screen, and hence the text
    is so stretched it is totally unreadable. The console text is also bright
    green, I assume something to do with the fact that my game changes the
    screen depth from 32 bit to 16 bit.

and

  1. The bottom 4/5 of the screen is a very mangled version of the last
    thing my game left in video memory

Typing “startx” succesfully restarts X and the screen goes back to normal.

However, once this bug has occured then my game kills X on calling
SDL_Quit() every single time it is run, until I restart my computer at
which point it returns to having about a 1 in 10 chance of happening each
time.

On a couple of occasions I have reproduced this bug in a different way: by
trying to run my game in DGA mode without root permissions. Normally this
causes SDL_setVideoMode to segfault and returns gracefully to the console,
but again maybe 1 in 10 times or similar this has the effect of killing X
and leaving you with a console squeezed into the top 1/5 of the screen
with bright green text.

Is there some way I might help find out exactly what is causing this?

James

Perhaps one out of ten times that I run my program in DGA mode X will die
when SDL_Quit() is called.

Oh, I forgot to say, by “one in ten times” I don’t mean I can sit there
going run-quit-run-quit-run-quit 10 times and it will probably crash.

If I do that it either crashes the first time and every time, or doesn’t
ever crash. There is evidently something else somewhere I do that sets
something somewhere differently such that it crashes, and I must do this
thing about 1 in 10 times before running my program.

JamesOn Wed, 14 Apr 2004 20:37:46 +0100, James Gregory wrote:

James Gregory wrote:>On Wed, 14 Apr 2004 20:37:46 +0100, James Gregory wrote:

Perhaps one out of ten times that I run my program in DGA mode X will die
when SDL_Quit() is called.

Oh, I forgot to say, by “one in ten times” I don’t mean I can sit there
going run-quit-run-quit-run-quit 10 times and it will probably crash.

If I do that it either crashes the first time and every time, or doesn’t
ever crash. There is evidently something else somewhere I do that sets
something somewhere differently such that it crashes, and I must do this
thing about 1 in 10 times before running my program.

Do you have SDL sound in your program ?
If so, does it still crash if you disable all the sound (i.e. comment
out all sound init & functions) ?

Stephane

James Gregory wrote:

Perhaps one out of ten times that I run my program in DGA mode X will die
when SDL_Quit() is called.

Oh, I forgot to say, by “one in ten times” I don’t mean I can sit there
going run-quit-run-quit-run-quit 10 times and it will probably crash.

If I do that it either crashes the first time and every time, or doesn’t
ever crash. There is evidently something else somewhere I do that sets
something somewhere differently such that it crashes, and I must do this
thing about 1 in 10 times before running my program.

Do you have SDL sound in your program ?

Yes, I use SDL_mixer.

If so, does it still crash if you disable all the sound (i.e. comment
out all sound init & functions) ?

Well, I already have a -nosound command line option which disables audio
initialization. I guess I can try using that half the time I run it
for the next few weeks (it’ll have to be a few weeks because I’m busy
with other things atm and hence won’t be running it much) and see if it
only crashes at times when I don’t specify that option.

I can’t just test it by disabling sound and running it once to see if
it crashes, as 9/10 times I know it won’t…

JamesOn Thu, 15 Apr 2004 00:21:12 +0200, Stephane Marchesin wrote:

On Wed, 14 Apr 2004 20:37:46 +0100, James Gregory wrote:

Do you have SDL sound in your program ?

Yes, I use SDL_mixer.

If so, does it still crash if you disable all the sound (i.e. comment
out all sound init & functions) ?

Well, I already have a -nosound command line option which disables audio
initialization. I guess I can try using that half the time I run it
for the next few weeks (it’ll have to be a few weeks because I’m busy
with other things atm and hence won’t be running it much) and see if it
only crashes at times when I don’t specify that option.

I can’t just test it by disabling sound and running it once to see if
it crashes, as 9/10 times I know it won’t…

OK, -nosound definitely does have some sort of effect.

Something I forgot to mention as I thought it was irrelevant is that
sometimes when my game exits from dga mode the console you get returned to
is is either:

a) blank

or

b) Scrolling down for ever, as though I was holding down the enter key.

Right at this moment in time dga isn’t causing it to crash, but it is
causing blank and scrolling consoles. Using the -nosound flag removes this
effect.

JamesOn Thu, 15 Apr 2004 00:26:49 +0100, James Gregory wrote:

OK, -nosound definitely does have some sort of effect.

Something I forgot to mention as I thought it was irrelevant is that
sometimes when my game exits from dga mode the console you get returned to
is is either:

a) blank

or

b) Scrolling down for ever, as though I was holding down the enter key.

As in, the xterm console that I run things from in X.

JamesOn Thu, 15 Apr 2004 01:02:37 +0100, James Gregory wrote:

James Gregory wrote:

If so, does it still crash if you disable all the sound (i.e. comment
out all sound init & functions) ?

Well, I already have a -nosound command line option which disables audio
initialization. I guess I can try using that half the time I run it
for the next few weeks (it’ll have to be a few weeks because I’m busy
with other things atm and hence won’t be running it much) and see if it
only crashes at times when I don’t specify that option.

I can’t just test it by disabling sound and running it once to see if
it crashes, as 9/10 times I know it won’t…

Yes, I understant your trouble, I have it with an OpenGL app of mine. I
didn’t solve it yet, but I just found that was (more or less) related to
sound. Do you have the source code for your app available, so maybe we
could compare with mine to see where the problem lies ?
It seems to me the crash happens inside the sound thread, when the
program quits.

Also, a “make clean ; make” cycle usually increases the probability of
reproducing that problem for me.

Stephane

Perhaps one out of ten times that I run my program in DGA mode X will die
when SDL_Quit() is called.

By “X dies” I mean, I am returned to the console, except:

  1. The console only occupies the top 1/5 of the screen, and hence the text
    is so stretched it is totally unreadable. The console text is also bright
    green, I assume something to do with the fact that my game changes the
    screen depth from 32 bit to 16 bit.

and

  1. The bottom 4/5 of the screen is a very mangled version of the last
    thing my game left in video memory

Typing “startx” succesfully restarts X and the screen goes back to normal.

However, once this bug has occured then my game kills X on calling
SDL_Quit() every single time it is run, until I restart my computer at
which point it returns to having about a 1 in 10 chance of happening each
time.

On a couple of occasions I have reproduced this bug in a different way: by
trying to run my game in DGA mode without root permissions. Normally this
causes SDL_setVideoMode to segfault and returns gracefully to the console,
but again maybe 1 in 10 times or similar this has the effect of killing X
and leaving you with a console squeezed into the top 1/5 of the screen
with bright green text.

Is there some way I might help find out exactly what is causing this?

This problem sounds like a memory corruption problem. If you haven’t
done it recently update your graphics drivers and X server to the latest
versions for you distribution. If you still get the problem then very
carefully trace all you DGA memory access to make sure you aren’t going
off the edge of the screen. It is easy to have an “off by one” problem
with clipping that will write into parts of memory you don’t want to
write. The fact that the X server is crashing indicates that something
it depends on is getting wiped out.

	Bob PendletonOn Wed, 2004-04-14 at 14:37, James Gregory wrote:

James


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

±--------------------------------------+

Yes, I understant your trouble, I have it with an OpenGL app of mine. I
didn’t solve it yet, but I just found that was (more or less) related to
sound. Do you have the source code for your app available, so maybe we
could compare with mine to see where the problem lies ?
It seems to me the crash happens inside the sound thread, when the
program quits.

Well, given that I have reproduced this crash in my game’s init function
and not only in the shutdown function, I can’t see how
the source code really affects it - i.e. the crash has happened before
I ever load any graphics or sound.

I’d have thought it was probably more to do with a certain combination of
graphics/sound drivers or whatever.

Still, if you want to check the game’s source nevertheless, it can be
downloaded as a bzipped tarball from:

http://galaxyhack.sourceforge.net/download.php

or you can view it on the web by following the view CVS link somewhere on:

Also, a “make clean ; make” cycle usually increases the probability of
reproducing that problem for me.

OK, I’ll watch out for whether this is a pattern.

However, another problem in finding out what is going on is that whenever
I am debugging my application, I run it in windowed mode, which means I
rarely have any reason to run it in dga mode unless I actually feel like
playing my own game…

JamesOn Thu, 15 Apr 2004 20:04:52 +0200, Stephane Marchesin wrote: