Segmentation fault

hi everybody!
I’m trying to write a DivX player application. I want to use SDL threads. The
application runs fine (opens DivX file, displays video frames, sound is ok
etc.). After less than 1 hour I get a segmentation fault message and the
application ends. I use Oss to play sound frames (decoded via MAD).
Any idea?
luigi

Can you be more specific? perhaps compile with debugging enabled
(gcc -g) and no optimizations.
then use gdb or similar to debug the program. thes will help tell you where
the segfault happenedOn Monday 24 February 2003 11:23 am, luigi wrote:

hi everybody!
I’m trying to write a DivX player application. I want to use SDL threads.
The application runs fine (opens DivX file, displays video frames, sound is
ok etc.). After less than 1 hour I get a segmentation fault message and the
application ends. I use Oss to play sound frames (decoded via MAD). Any
idea?
luigi


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

Maybe, you have memory leaks. Are you freeing each unused memory area ?

Julien> ----- Original Message -----

From: taxtropel_news@yahoo.com (Samuel E. Bray)
To:
Sent: Wednesday, February 26, 2003 9:40 AM
Subject: Re: [SDL] segmentation fault

Can you be more specific? perhaps compile with debugging enabled
(gcc -g) and no optimizations.
then use gdb or similar to debug the program. thes will help tell you
where
the segfault happened

On Monday 24 February 2003 11:23 am, luigi wrote:

hi everybody!
I’m trying to write a DivX player application. I want to use SDL
threads.

The application runs fine (opens DivX file, displays video frames, sound
is

ok etc.). After less than 1 hour I get a segmentation fault message and
the

application ends. I use Oss to play sound frames (decoded via MAD). Any
idea?
luigi


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, out of curiosity, can a memory leak cause a segmentation fault?
I can see how it would generate an “out of memory”- error or, more likely, cause
your os to start writing memorypages to disk. But I fail to see where it would
cause a Segmentation fault.

/Pontus> Maybe, you have memory leaks. Are you freeing each unused memory area ?

Julien

----- Original Message -----
From: “Samuel” <taxtropel_news at yahoo.com>
To:
Sent: Wednesday, February 26, 2003 9:40 AM
Subject: Re: [SDL] segmentation fault

Hi all,

If I try to compile my SDL game in a CygWin environment I get conflicts with default cygwin headers (at least, that is what I think is going on)

For example, this is a error that I get:

[ERRORLOG]
g++ -O -Wall -Wimplicit sdl-config --cflags -c mainmenu.cpp -o mainmenu.o
mainmenu.cpp: In member function virtual void ttMainmenu::Init()': mainmenu.cpp:23: cannot convertconst char*’ to HINSTANCE__*' for argument1
’ to `void* LoadImageA(HINSTANCE__, const CHAR, unsigned int, int, int,
unsigned int)'
make: *** [mainmenu.o] Error 1
[/ERRORLOG]

And this is the LoadImage function (don’t know why an A is added??)

LoadImage( "gfx/menu.png" );

and LoadImage is inherited code as follows

bool dlpSDLobj::LoadImage(char *filename) { SDL_Surface *temp; temp = IMG_Load( filename ); if(temp==NULL){ #ifdef DEBUG printf("dlpSDLobj::loadImage(): error loading %s; %s.\n", filename, SDL_GetError()); #endif return false; } surface = SDL_DisplayFormat(temp); if(surface == NULL ){ #ifdef DEBUG printf("dlpSDLobj::loadImage(): error copying temp to surface.\n"); #endif return false; } SDL_FreeSurface(temp); #ifdef MEMORY printf("[LOADED] %s at %d\n", name, surface ); #endif MEMORY return true; }

How can I avoid these conflicts, any ideas?

Thanks in advance!
Rob_____________________________________________________________________
Zon Breedband Family, 2 keer zo snel als alle andere ADSL aanbieders.
Voor maar 34 euro per maand.
Bestel nu op www.zonnet.nl/breedband en krijg het modem gratis.

How, out of curiosity, can a memory leak cause a segmentation fault?
I can see how it would generate an “out of memory”- error or, more likely, cause
your os to start writing memorypages to disk. But I fail to see where it would
cause a Segmentation fault.

The easiest way is for malloc (or new) to return NULL and for the
program to not check it. Then, using NULL as a pointer will, with luck,
generate a segmentation error. The other way is that the reverse of a
memory leak causes the problem. If you free memory that is still in use,
and then it gets allocated and initialized as a different kind of
data… well, what you thought was a pointer now has characters or
something else in it and dereferencing the data as a pointer usually
gives you a seg fault. Of course, you can get a seg fault from the usual
ways too, memory corruption caused by indexing out side of an array. My
personal favorite is concatenating strings without to make sure the
result will fit in the destination buffer :slight_smile:

When a program runs for a hour, and then crashes with a seg fault it is
usually the result of memory corruption. But, it is not always the
result of memory corruption.

	Bob PendletonOn Wed, 2003-02-26 at 04:02, Pontus Pihlgren wrote:

/Pontus

Maybe, you have memory leaks. Are you freeing each unused memory area ?

Julien

----- Original Message -----
From: “Samuel” <taxtropel_news at yahoo.com>
To:
Sent: Wednesday, February 26, 2003 9:40 AM
Subject: Re: [SDL] segmentation fault


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

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

2003-02-26 17:02:49, Bob Pendleton wrote:>On Wed, 2003-02-26 at 04:02, Pontus Pihlgren wrote:

How, out of curiosity, can a memory leak cause a segmentation fault?

The easiest way is for malloc (or new) to return NULL and for the
program to not check it. Then, using NULL as a pointer will, with luck,

Standard new will throw, not return NULL, and the runtime library – I’m guessing – could possibly do
whatever it wants if that exception pass the end of main(), including segfaulting.