User forums > General (but related to Code::Blocks)

Only runs in debug mode

(1/2) > >>

purpleyouko:
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.

--- Code: ---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;
        }
--- End code ---
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.

--- Code: ---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;
        }
--- End code ---
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?

oBFusCATed:
Read the rules of the forum and then ask your question in an appropriate forum/mailing list.

purpleyouko:

--- Quote from: oBFusCATed on May 23, 2012, 05:20:16 pm ---Read the rules of the forum and then ask your question in an appropriate forum/mailing list.

--- End quote ---
Thanks for the advice.

I have read the rules quite thoroughly.
I always do when posting to a new board since I never like to annoy anyone by posting in the wrong place. I own several boards myself and moderate many others so I know how annoying it can be.

First I used the search function to attempt to find any mention of this issue. It came up with nothing useful which isn't really surprising. The search functions on most forums either turn up nothing or 20 million posts. That's just the nature of busy forums and something we have to live with.

As to asking my question in an appropriate forum, I was under the impression that this one was the one to use when the subject doesn't quite fit anywhere else.
The only other possibility might be the "Help" forum. I carefully weighed up whether to post there or here and based on other threads and their content, this one seemed to be the most appropriate. 
I could have posted in both but that is usually frowned upon so I chose here.

oBFusCATed:

--- Quote from: purpleyouko on May 23, 2012, 06:11:19 pm ---I have read the rules quite thoroughly.

--- End quote ---
Yeah, right I believe you...

http://forums.codeblocks.org/index.php/topic,9996.0.html

--- Quote ---1. This is NOT a general programming board. "How do I write a program that....", "Can anybody teach me how to", "I have this homework",  "My program doesn't run and I don't have the slightest idea of why because I'm a C++ newcomer", "What is a compiler", "What does gcc do" is the kind of questions that is FORBIDDEN to ask.

--- End quote ---

purpleyouko:

--- Quote from: oBFusCATed on May 23, 2012, 06:31:44 pm ---
--- Quote from: purpleyouko on May 23, 2012, 06:11:19 pm ---I have read the rules quite thoroughly.

--- End quote ---
Yeah, right I believe you...

http://forums.codeblocks.org/index.php/topic,9996.0.html

--- Quote ---1. This is NOT a general programming board. "How do I write a program that....", "Can anybody teach me how to", "I have this homework",  "My program doesn't run and I don't have the slightest idea of why because I'm a C++ newcomer", "What is a compiler", "What does gcc do" is the kind of questions that is FORBIDDEN to ask.

--- End quote ---


--- End quote ---
Except that is really not the question I'm asking is it?
My program runs quite nicely... in debug mode.
And it has been running just fine as as exe since 2005 when I first wrote it. It randomly stopped working last week.
I've been programming C++ since 1993 and other languages for 20 years prior to that.
I'm not really what you might describe as a newcomer at C++ or any other computer language.

Navigation

[0] Message Index

[#] Next page

Go to full version