[SDL] Program crashes in release build

Mybowlcut mybowlcut at hotmail.com
Wed Apr 15 17:14:53 PDT 2009



fuzzyTew wrote:
> 
> On Wed, Apr 15, 2009 at 9:57 AM, Mybowlcut <mybowlcut at hotmail.com> wrote:
>> I was just experimenting then, and I found that excluding all the other
>> source files except main and bringing main down to this fixes the
>> problem:
>>
>> #include "sdl.h"
>>
>> int main(int argc, char* argv[])
>> {
>>        return 0;
>> }
>>
>> Unfortunately, this leaves me with no Checkers game to play. I've been
>> deleting folders and files and rebuilding for almost an hour now...
>> please
>> someone tell me I don't have to do this for each source/header file in my
>> project until I find the offending file. :)
> 
> Ah, so it is indeed something outside main being linked in.  Don't
> worry about header files.  The problem is probably from the destructor
> of an object defined statically or at file scope.  Stepping through in
> a debugger should help a lot.  If that is not an option for some
> reason, you're stuck with either inspection of your source or adding
> and removing .cpp files until you find which one causes it.
> 
>>From the little I see, it really looks like one of your singletons
> fails to initialise a pointer in its constructor.  This singleton
> probably defines a static instance of itself to save you from
> initialising it, so it doesn't matter whether main references it or
> not.  Do you have no backtrace of the exception?
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
> 
> 

Found it. The reason I'm not excited is because I am SCARED. Here is the
offending header file (which holds a struct I never even used :@):

#ifndef SDL_TOOLS_H
#define SDL_TOOLS_H

#include "include_ticpp.h"

#include "SDL.h"

namespace SDL_Tools
{
	// A readable/writeable SDL_Rect.
	struct RW_SDL_Rect : public SDL_Rect//, public ticpp::Element_RW
	{
		RW_SDL_Rect();
		RW_SDL_Rect(Sint16 x, Sint16 y, Uint16 w, Uint16 h);

		virtual void Read(ticpp::Element* element);
		virtual void Write(ticpp::Element* element) const;
	};
}

#endif

Here is the offending source file:

#include "SDL_Tools.h"

SDL_Tools::RW_SDL_Rect::RW_SDL_Rect()
{
}

SDL_Tools::RW_SDL_Rect::RW_SDL_Rect(Sint16 x, Sint16 y, Uint16 w, Uint16 h)
{
	this->x = x;
	this->y = y;
	this->w = w;
	this->h = h;
}

void SDL_Tools::RW_SDL_Rect::Read(ticpp::Element* element)
{
    // TODO: Uncomment! Is temp until release crash bug is found!
	//ticpp::throw_on_bad_element(element, __FILE__);

	x = element->GetAttribute<Sint16>("x");
	y = element->GetAttribute<Sint16>("y");
	w = element->GetAttribute<Uint16>("w");
	h = element->GetAttribute<Uint16>("h");
}

void SDL_Tools::RW_SDL_Rect::Write(ticpp::Element* element) const
{
    // TODO: Uncomment! Is temp until release crash bug is found!
	//ticpp::throw_on_bad_element(element, __FILE__);

	element->SetAttribute("x", x);
	element->SetAttribute("y", y);
	element->SetAttribute("w", w);
	element->SetAttribute("h", h);
}
SDL_Tools::RW_SDL_Rect::RW_SDL_Rect(Sint16 x, Sint16 y, Uint16 w, Uint16 h)
{
	this->x = x;
	this->y = y;
	this->w = w;
	this->h = h;
}

The scary part is that include_ticpp.h is excluded from my build completely.
The calls to throw_on_bad_element produce linker errors if I uncomment them,
yet my code is happy to use ticpp::Element... can anyone please explain this
before my head explodes?

Cheers.
-- 
View this message in context: http://www.nabble.com/Program-crashes-in-release-build-tp22654119p23069172.html
Sent from the SDL mailing list archive at Nabble.com.




More information about the SDL mailing list