Serious bug in SDL_Init, SDL_SetVideoMode or SDl_PollEvent?

Anoq of the Sun wrote:

Hello!

I’m pretty sure that I have found a bug in SDL
which provokes a segmentation fault. It could
be a bug in my SDL::ML code or the ML-compiler
I’m using - but I think the chances of that
are minimal… :slight_smile:

The only SDL functions I am calling in
my program are:

SDL_Init(INIT_VIDEO)
SDL_SetVideoMode(SDL_SWSURFACE, …)
SDL_PollEvent(&event)

I have an SDL_Quit call in the app too - but
it segfaults before it reaches that.

dont know if this is it but SDL_SWSURFACE should be the fourth argument.

Hello!

I’m pretty sure that I have found a bug in SDL
which provokes a segmentation fault. It could
be a bug in my SDL::ML code or the ML-compiler
I’m using - but I think the chances of that
are minimal… :slight_smile:

The only SDL functions I am calling in
my program are:

SDL_Init(INIT_VIDEO)
SDL_SetVideoMode(SDL_SWSURFACE, …)
SDL_PollEvent(&event)

I have an SDL_Quit call in the app too - but
it segfaults before it reaches that.

This happens in both SDL-1.1.8 and SDL-1.2.0 -
on Linux for once! :slight_smile:

I can send the C-code (for compiling with gcc)
that the ML-compiler generated - in case
anybody (Sam? :slight_smile: would like to do a debug
trace or something :slight_smile:

Cheers–
http://www.HardcoreProcessing.com

Did you write a simple C Prog too ??? To test if it is a bug of the ML
Compiler ???

CU

“Anoq of the Sun” schrieb im Newsbeitrag news:3B069277.9EDEB997 at HardcoreProcessing.com…> Hello!

I’m pretty sure that I have found a bug in SDL
which provokes a segmentation fault. It could
be a bug in my SDL::ML code or the ML-compiler
I’m using - but I think the chances of that
are minimal… :slight_smile:

The only SDL functions I am calling in
my program are:

SDL_Init(INIT_VIDEO)
SDL_SetVideoMode(SDL_SWSURFACE, …)
SDL_PollEvent(&event)

I have an SDL_Quit call in the app too - but
it segfaults before it reaches that.

This happens in both SDL-1.1.8 and SDL-1.2.0 -
on Linux for once! :slight_smile:

I can send the C-code (for compiling with gcc)
that the ML-compiler generated - in case
anybody (Sam? :slight_smile: would like to do a debug
trace or something :slight_smile:

Cheers

http://www.HardcoreProcessing.com

Patrick McCarter wrote:

SDL_Init(INIT_VIDEO)
SDL_SetVideoMode(SDL_SWSURFACE, …)
SDL_PollEvent(&event)

I have an SDL_Quit call in the app too - but
it segfaults before it reaches that.

dont know if this is it but SDL_SWSURFACE should be the fourth argument.

OK - it’s not that, the above was only meant as pseudocode :slight_smile:

Torsten Giebl wrote:

Did you write a simple C Prog too ??? To test if it is a bug of the ML
Compiler ???

I can’t seem to get programs which are very simple
to crash. It only happens when I modify the programs
in a sufficiently obscure way. But if it’s a segfault,
then the error really can occur at any time. And the ML-
compiler is tossing around a lot of memory because of
the garbage collection, so this might be just what is
triggering the bug. I tried doing some stress-testing of
SDL_Init and SDL_SetVideoMode earlier, but I couldn’t
get that to crash. I haven’t tried stresstesting
SDL_PollEvent though…

But regarding the ML-compiler - I’ve got a 30.000 line
commercial app written in ML compiled with the same
compiler, and I’ve never seen it segfault. And all
my other 100% ML-apps doesn’t crash like that either.
On the other hand, virtually all SDL-programs I’ve
written which are more than a few lines of code
(both those in C/C++ and those in ML) always seem
to be unstable… it wasn’t really bad when using the
good ol’ stable version 0.9.9 of SDL, but even then
it happened, but with later versions of SDL it’s
worse. So I’m pretty sure there’s some serious
bug somewhere, but this is the closest I’ve
been able to come to isolating it.

Cheers–
http://www.HardcoreProcessing.com

Anoq of the Sun wrote:

But regarding the ML-compiler - I’ve got a 30.000 line
commercial app written in ML compiled with the same
compiler, and I’ve never seen it segfault. And all
my other 100% ML-apps doesn’t crash like that either.
On the other hand, virtually all SDL-programs I’ve
written which are more than a few lines of code
(both those in C/C++ and those in ML) always seem
to be unstable… it wasn’t really bad when using the
good ol’ stable version 0.9.9 of SDL, but even then
it happened, but with later versions of SDL it’s
worse. So I’m pretty sure there’s some serious
bug somewhere, but this is the closest I’ve
been able to come to isolating it.

Graphics code can be hard to write. Since no one else is experiencing
these “bugs”, its probably just your code. Run a debugger (I don’t know
the specifics to ML) on your segfaulting program and when it crashes do
the equivalent of a “backtrace” in gdb. This will point you to the
offending code (either in SDL or your own) …

-- David Snopek

/-- libksd –
| The C++ Cross-Platform Game Framework
| Only want to write it once??
| http://libksd.sourceforge.net
------------

OK - I found out that there’s no bug in SDL
afterall… I replaced all the C-calls to SDL
with dummy functions returning the same
values as the SDL functions as called in my
program - and I now get the segfault without
including or linking to SDL!

I’m very sorry about this!

I will redirect the bugreport to the compiler
writers… (since an ML program cannot do things
like segfault if the compiler is correct).

But thanks for the comments about debugging and
what not…

Cheers–
http://www.HardcoreProcessing.com