News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

re: console runner message "process returned 3"

Started by bala_48225, April 27, 2010, 06:00:31 PM

Previous topic - Next topic

bala_48225

Hello, I am:  Windows xp, codeblocks 8.02, MingW compiler.

The Console runner says "process returned 3" and the build log says "process terminated with status 3".  I had some problems prior with the program which is why I noticed that message, however now it runs fine now with my changes.  Nonetheless, I'm curious  as to what that number means and if it's significant, in case it's some kind of runtime error code.  Thx in advance for answers! -B  :)

ptDev

The status number is nothing special from Code::Blocks. Either you had somewhere a 'return 3;' or equivalent in your main(), or an exception called exit(3). It's just the old error status return value that C++ inherited from C.


bala_48225

#3
I would now like to bring this (old) topic to a conclusion:  the reason the Console message window was saying "process returned 3" was for one and only one reason:  freeing a nonexistent SDL surface from an array of surfaces, e.g. for(i=0;i<6;i++) SDL_FreeSurface(img[i]);  So... if you get this sort of response (process returned 3), consider pressing F8 instead of F9 (to run the debugger along with your program); this will find the segfault and you'll see what your mistake was.  Alternatively, you could set the pointer to NULL at the beginning of the program and free the surface in your freeing loop at the end.  The impression I'm under is you can also not free it, since it points to nothing in the first place.    

Edit November 2, 2011:  The above isn't quite right, you should 1) initialize the surface to NULL at the start of the program.  2) freeing it at the end should be fine (as above), but to be pedantic:

for(i=0; i<6; i++)
{
   if(img[i] != NULL)
   {
       SDL_FreeSurface(img[i]);
       img[i] = NULL;
   }
}


and at the beginning, always:
SDL_Surface img[6];
for(Uint8 i = 0; i < 6; i ++)
   img[i] = NULL;
// then load


This topic has been read 1600 times, so I thought I would "point" people in the right direction.