Mysterious segmentation fault

Hi all,
I’m new to SDL.
I’ll try to explain my problem. I’m currently working on a simple shoot’em up
engine, using SDL for its multi platform compatibility.
I’m having some strange segmentation fault, while blitting surface on screen
(especially when using SDL_RLEACCEL), when calling SDL_Quit(), or while freeing
surfaces.
Here is the call stack while freeing:
8: malloc_trim()
7: free()
6: SDL_FreeSurface()
(…)

While drawing software surface:
*** glibc detected *** malloc(): memory corruption: 0x00000000005395d0 ***
And the stack:
19: raise()
18: abort()
17: __fsetlocking()
16: free()
15: malloc()
14: SDL_RLESurface()

The bug occurs both on windows and linux.

Many thanks,
Fred

No offense but without seeing some of your code, we can’t do much.

  • SROn 10/28/05, Fred wrote:

Hi all,
I’m new to SDL.
I’ll try to explain my problem. I’m currently working on a simple shoot’em up
engine, using SDL for its multi platform compatibility.
I’m having some strange segmentation fault, while blitting surface on screen
(especially when using SDL_RLEACCEL), when calling SDL_Quit(), or while freeing
surfaces.
Here is the call stack while freeing:
8: malloc_trim()
7: free()
6: SDL_FreeSurface()
(…)

While drawing software surface:
*** glibc detected *** malloc(): memory corruption: 0x00000000005395d0 ***
And the stack:
19: raise()
18: abort()
17: __fsetlocking()
16: free()
15: malloc()
14: SDL_RLESurface()

The bug occurs both on windows and linux.

Many thanks,
Fred

Simon Roby <simon.roby gmail.com> writes:

No offense but without seeing some of your code, we can’t do much.

  • SR

Ok sorry, but I don’t know which piece of code to post.
On the other hand, I discovered that the segmentation fault occured after a call
to malloc (not immediately after!). Otherwise I don’t know how I could proceed ,
and why that generates an error.

Have you tryed some tool like Valgrind ?On 10/29/05, Fred wrote:

Simon Roby <simon.roby gmail.com http://gmail.com> writes:

No offense but without seeing some of your code, we can’t do much.

  • SR

Ok sorry, but I don’t know which piece of code to post.
On the other hand, I discovered that the segmentation fault occured after
a call
to malloc (not immediately after!). Otherwise I don’t know how I could
proceed ,
and why that generates an error.


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

You could try the old fashioned way: put printf()s in your code and
see how far it gets…

ChrisOn 10/29/05, Fred wrote:

Ok sorry, but I don’t know which piece of code to post.
On the other hand, I discovered that the segmentation fault occured after a call
to malloc (not immediately after!). Otherwise I don’t know how I could proceed ,
and why that generates an error.


E-Mail: Chris Nystrom
Business: http://www.shaklee.net/austin
Blog: http://conversazione.blogspot.com/
AIM: nystromchris

Chris Nystrom <cnystrom gmail.com> writes:

You could try the old fashioned way: put printf()s in your code and
see how far it gets…

Chris


E-Mail: Chris Nystrom <cnystrom gmail.com>
Business: http://www.shaklee.net/austin
Blog: http://conversazione.blogspot.com/
AIM: nystromchris

Thanks to both of you. There was a buffer overflow and a problem with surfaces
locking.
Sorry for disturbing.