i have a strange problem with a project.
It compiles fine but when I run it from the executable it crashes in a very strange place.
First it fails to alocate memory for some of my variables then after trying (and failing) to load data from about 4 different functions it finally crashes completely
this is the code in which it fails to allocate the memory.
Log( MSG_INFO, "Loading Sell Data" );
//Log(MSG_WARNING,"STB rowcount: %i",STB_SELL.rowcount );
for(unsigned int i=0;i<STB_SELL.rowcount;i++)
{
//Log( MSG_INFO, "Sell Data row %i",i );
CCSellData* newsell = new (nothrow) CCSellData;
if(newsell == NULL)
{
Log(MSG_WARNING, "\nError Allocing memory: sell" );
return false;
}
The commented Log commands (when uncommented) show that STB_SELL.rowcount is around 500 so it's not that which is causing the issue.
When i run the EXE it just spits out the MSG_WARNING and returns false.
It apparently isn't creating "newsell"
The CCSellData structure is perfectly OK. It hasn't been changed for years and has always worked till a rebuild last week.
It goes on to do the same thing in 3 other loading subroutines before finally giving up on this one.
Log( MSG_INFO, "Loading Jem Data " );
for(unsigned int i=0;i<STB_ITEM[10].rowcount;i++)
{
CJemData* thisjem = new (nothrow) CJemData;
if(thisjem == NULL)
{
Log(MSG_WARNING, "\nError allocing memory: jemitem" );
continue;
}
this time all it does is print out "Loading Jem Data" then it just crashes completely with a message that the program terminated in an unusual way. (is there a usual way to crash i wonder?)
The really strange thing is that when I run the project directly from the debugger in CodeBlocks it runs flawlessly.
This error only occurs in the executable.
Another strange thing is that changing something totally unrelated in another part of the project then rebuilding the whole thing
sometimes (about 1 build in 10) results in a working exe but it always works from the debugger.
Any suggestions?