Hi everyone. I wanted to try something different for a bit, but for some reason the little program I wrote crashes. I’ve pin-pointed the line where it crashes, then commented out and removed other parts of the program, replaced variable numbers by fixed ones, even made a simple testcase. Nothing is helping to debug this, and it’s driving me nuts.
The crash happens in GameEngine::blitToScreen when it calls SDL_BlitSurface, but only when the former was called from Sonic::draw.
You can get the files at http://users.skynet.be/fa258499/temp/project.zip.
Thanks in advance!
After some more testing, I determined that there’s something wrong with the SDL_Surface m_spriteSheet I use. If I never blit it, then the program crashes when I try to free it using SDL_FreeSurface. Yet I detect no error from the returns of SDL_LoadBMP and SDL_SetColorKey.
No one can help you without seeing the code. There wasn’t a link in your
prior post.From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of BenoitRen
Sent: Sunday, October 17, 2010 5:34 PM
To: sdl at lists.libsdl.org
Subject: Re: [SDL] HELP! Crash bug is driving me nuts
After some more testing, I determined that there’s something wrong with the
SDL_Surface m_spriteSheet I use. If I never blit it, then the program
crashes when I try to free it using SDL_FreeSurface. Yet I detect no error
from the returns of SDL_LoadBMP and SDL_SetColorKey.
There is a link, but it gets munched by the newsgroup client’s HTML parser as I used guillemets around the link (which creates a link in text posts). Here is the URL again: http://users.skynet.be/fa258499/temp/project.zip
this is not correct c++ code and does not compile, gameengine.h has const
enum inputDirections, and just below struct Controls with int direction
and you try to use that as the enumeration.
its an enum or an int, dont use both.On Mon, 18 Oct 2010, BenoitRen wrote:
There is a link, but it gets munched by the newsgroup client’s HTML parser as I used guillemets around the link (which creates a link in text posts). Here is the URL again: http://users.skynet.be/fa258499/temp/project.zip
mattmatteh wrote:
this is not correct c++ code and does not compile, gameengine.h has const
enum inputDirections, and just below struct Controls with int direction
and you try to use that as the enumeration.
its an enum or an int, dont use both.
Thanks for the bug report. I fixed that, but as suspected it didn’t fix my crash bug.
I debugged it again, and noticed that the pointer value was changed by the time the destructor was reached. So something has been changing it.
I stepped through the program while watching the member, and noticed that it changed in the middle of filling in some arrays. Then it hit me; I’m writing outside of the array’s boundaries! Stupid me!