Page 1 of 2

Project broken beyond repair

Posted: Sat Dec 20, 2008 3:24 pm
by dandymcgee
:oops: :cry:
My project is broken. Very very broken. I can't even isolate the error to post here for help.
Process terminated with status 3 (0 minutes, 6 seconds)
That is the message I've been looking at for the past 8 hours. I've been outputting line numbers to my debug text file to see exactly where it was crashing, because Code::Blocks' debugger no longer works, at all.

I would change something around to make it get past the line it crashes on (there are zero compile errors so I don't know what's wrong with what's already there), and then it would crash like 5 lines after that one. I'm pretty sure my only choice is to start over from the last backup I have, unless someone else can think of some other way I can attempt to debug the failure?

Re: Project broken beyond repair

Posted: Mon Dec 22, 2008 12:47 pm
by bugmenot
Without code, it is a little difficult to help.

My guess is that it is due to a memory stump. Going beyond the bounds of an array, deleting something off the stack, uninitialised variables, double deleting, etc.

Are you building and running in Debug mode? Are you running the project with the debugger attached?

Are you using any form of source control?

Re: Project broken beyond repair

Posted: Mon Dec 22, 2008 1:37 pm
by programmerinprogress
yeah, when I get status 3's, It's usually due to something to do with pointers, if it's an SDL project your working on, check that all of your SDL_Surfaces are being created, initialised to NULL and are being freed properly, I swear I got a status 3 and something like that was wrong.

I don't know why, but I always hate getting status 3, I think it must be because i've gotten used to seeing it, and it normally means i've done something terrible :(

Nothing says "good job" like a nice clean status 0 :)

Re: Project broken beyond repair

Posted: Mon Dec 22, 2008 4:47 pm
by dandymcgee
bugmenot wrote:Without code, it is a little difficult to help.
My guess is that it is due to a memory stump. Going beyond the bounds of an array, deleting something off the stack, uninitialised variables, double deleting, etc.
I'll check that out next time I feel like dealing with debugging my messy code (when vacation starts) :)
bugmenot wrote:Are you using any form of source control?
I'm not sure what you mean by source control? Do you have an example?
bugmenot wrote:Without code, it is a little difficult to help.
Well as I've said I can't even figure out what file the error is starting in, and the whole project is somewhere around 700 lines.
programmerinprogress wrote:Nothing says "good job" like a nice clean status 0 :)
Haha, that's for sure. I'll take a look at the things you mentioned.

Re: Project broken beyond repair

Posted: Mon Dec 22, 2008 5:35 pm
by bugmenot
dandymcgee wrote:I'm not sure what you mean by source control? Do you have an example?
SVN, git, CVS, Perforce.
dandymcgee wrote: Well as I've said I can't even figure out what file the error is starting in, and the whole project is somewhere around 700 lines.
That is small enough. Post the whole project.

Re: Project broken beyond repair

Posted: Tue Dec 23, 2008 1:39 am
by Falco Girgis
Didn't you say that this happened when you rewrote string code to use character arrays? That would fit the array out-of-bounds theory...

Re: Project broken beyond repair

Posted: Tue Dec 23, 2008 12:28 pm
by bugmenot
GyroVorbis wrote:Didn't you say that this happened when you rewrote string code to use character arrays? That would fit the array out-of-bounds theory...
C++ strings FTW.

Re: Project broken beyond repair

Posted: Thu Dec 25, 2008 8:41 pm
by dandymcgee
GyroVorbis wrote:Didn't you say that this happened when you rewrote string code to use character arrays? That would fit the array out-of-bounds theory...
Nope, I haven't rewritten any string code haha.
bugmenot wrote:
dandymcgee wrote: Well as I've said I can't even figure out what file the error is starting in, and the whole project is somewhere around 700 lines.
That is small enough. Post the whole project.
Alright, here ya go: http://www.freewebs.com/dandymcgee/Dand ... Broken.zip
Thanks for taking to time to look at this for me :mrgreen:

Btw, Merry Christmas everyone!

Re: Project broken beyond repair

Posted: Thu Dec 25, 2008 9:05 pm
by M_D_K
I might have something to do with this:

Code: Select all

Level *test;
test->Load( mapname, tilesheet );
test->Draw();
You need to do this(this means Level needs a constructor)

Code: Select all

Level *test = new Level();
And don't forget to delete it at the end.

Re: Project broken beyond repair

Posted: Sat Dec 27, 2008 2:39 am
by dandymcgee
M_D_K wrote:I might have something to do with this:

Code: Select all

Level *test;
test->Load( mapname, tilesheet );
test->Draw();
You need to do this(this means Level needs a constructor)

Code: Select all

Level *test = new Level();
And don't forget to delete it at the end.
What should I put in the constructor? I can't get this to fix the problem.

Re: Project broken beyond repair

Posted: Sat Dec 27, 2008 8:00 am
by M_D_K
Just leave the constructor blank for now.

Re: Project broken beyond repair

Posted: Sat Dec 27, 2008 12:27 pm
by dandymcgee
I tried it with a blank constructor and it returned status 3 just the same. :(

Re: Project broken beyond repair

Posted: Sat Dec 27, 2008 1:36 pm
by M_D_K
I noticed :/
Me thinks it has to do with you Image::Load function that seams to be where it dies still working it.

Re: Project broken beyond repair

Posted: Sat Dec 27, 2008 1:43 pm
by dandymcgee
Yeah.. but test.png exists in the images folder so I don't know why it wouldn't work? I've used that function before elsewhere I believe. Thanks for trying to help though, I really do appreciate it.

Re: Project broken beyond repair

Posted: Sun Dec 28, 2008 1:58 am
by bugmenot
From a very quick glance:

Code: Select all

    Level *test;
    test->Load( mapname, tilesheet );
    test->Draw();
Doesn't need to be a pointer:

Code: Select all

    Level test;
    test.Load( mapname, tilesheet );
    test.Draw();
In int Level::Load( std::string file_map, std::string file_tilesheet ):

Always pass objects as references and const whenever possible unless there is a design reason not to. It is cheaper and faster to pass by reference then by value for non-basic datatypes and the use of const is so you don't accidently overwrite the data:

Code: Select all

int Level::Load( const std::string & file_map, const std::string & file_tilesheet )

Code: Select all

    file_tilesheet = "images\\" + file_tilesheet;
    tileSheet->Load( file_tilesheet, TILE_WIDTH, TILE_HEIGHT, TILE_SPRITES );
tileSheet (which is currently a pointer) is not initialised or pointing to a valid memory address. Again it has no reason to be a pointer.

In short, most of your problems involve using pointers that are pointing to invalid memory.