# Release Configuration Runs Fine in IDE, but Crashes In Open Environment.

## Recommended Posts

Alrighty, I've made two simple libraries, one for graphics and networking in SDL. Now I've merged them into one project, just to see how I can do it. So when I run it w/the IDE, it works perfectly, no errors. But when I close the IDE, navigate to the actual .exe and run it; it crashes. I have determined by trial and error the location of this strange bug. In Test.cpp, the code portion I'm interested in is:
void hostUDP()
{

CSDLDevice device = CSDLDevice();
device.setScreen( 1024, 768, 32 );
CAnimImage image;

device.loadAnimImage( "image.bmp", 64, 64, image );

lib = new NetLib( NULL, -1 );
CUDPSocket sock = lib->openUDPConnection( 2006 );
CUDPMessage msg = lib->createUDPMessage( 512 );
bool quit = 0;
while( !quit )
//...

CResult CSDLDevice::loadAnimImage( std::string filePath, int height, int width, CAnimImage &image )
{
//COMMENTING OUT CANIMIMAGE DOESN'T STOP THE CRASH.
image = CAnimImage( filePath, height, width );
//CSDLDevice::setScreen already did a return CResult( RESULT_SUCCESS ),
//so this isn't the issue either.
return CResult( RESULT_SUCCESS );
}

So basically, that leaves the parameter list, and whatever default constructor may be getting called or something like that... but when I try to debug it and step through it, It won't let me into loadAnimImage... so as far as I can currently tell, the bug is in the parameter list somewhere. IDE: Visual C++ Express 2005 CONFIGURATION: Release. Note: Debug apparently crashes at the same time, when in open environ, but since its debug, I'll only need to run it in the IDE, but it's probably the same bug. Note: Also, I get an LNK4204/LNK4099. 'Corrupted' vc80.pdb file and 'missing'vc80.pdb file respectively. I believe this is preventing me from stepping through loadAnimImage. But I don't know how to solve this, enabling /Zi got me the 4204 and not doing so got me the 4099. Note: This is a multiproject solution. Test is in Project Test and the problem code is in Project Device. But that shouldn't really matter. Purpose of Code: To draw an animation of an explosion when it receives the string "draw" over the internet. If you need to see more of my code/project please ask. Problem1: Why does my proggy crash in open environ, but not IDE? Problem2: Why can't I step through certain methods, that are in another project? Does it have anything to do with LNK4204/4099?

##### Share on other sites
When running from the IDE, the current working directory is set to the project directory. (E.g. /MyProject/). When running the exe directly, the CWD is set to the directory containing the exe (E.g. /MyProject/Release/).

Since you're loading resources using relative paths (No C:\blah\foo\image.bmp or any other full path), loadAnimImage() will almost certainly be failing because it can't load the image. What does the implementation of the CAnimImage constructor look like? My guess is that you're assuming the load will succeed, and then using an invalid pointer (Either a C-file pointer, or something else).

##### Share on other sites
Well, I placed an image.bmp into the release directory too, but it still crashed. Although, since commenting out the constructor, and just returning, didn't actually solve the problem, and that my code still inits a CAnimImage, but with a null surface; that shouldn't be causing the crash I think.

Heres CAnimImage:
CAnimImage::CAnimImage( std::string fileName, int height, int width ) 	: CImage( fileName ){	frameHeight = height; 	frameWidth = width; 	//Make sure that the frame dimensions are compatible w/ surface dimensions 	if( surface-&gt;h % frameHeight == 0 ) 	{		if( surface-&gt;w % frameWidth == 0 )				{//Figure out how many frames we have 			totalFrameNum = ( surface-&gt;h / frameHeight ) * ( surface-&gt;w / frameWidth ); 			//Dynamic Alloc, remember to delete it 			frames = new SDL_Rect [ totalFrameNum ];						//Now, define the boundaries of each frame			for( int y = 0, i = 0; (y+1)*frameHeight &lt;= surface-&gt;h; y++ )			{				for( int x = 0; x*frameWidth &lt;= surface-&gt;w; x++, i++ )				{//Set the frame's x & y values 					frames[ i ].x = x*frameWidth; 					frames[ i ].y = y*frameHeight; 					frames[ i ].w = frameWidth;					frames[ i ].h = frameHeight;  				}				i--;//To compensate for i being incremented once too many times					//in previous loop			}		}		SDL_Surface* temp = SDL_CreateRGBSurface( surface-&gt;flags, frameWidth, frameHeight, 32, 8, 8, 8, 8 ); 		currentFrame = SDL_DisplayFormat( temp );  		setFrame( 0 ); //Set the current frame to the first frame. 	}}

and CImage
CImage::CImage( const std::string &fileName ){ 	SDL_Surface* temp = SDL_LoadBMP( fileName.c_str() ); 	if( temp != NULL )	{		surface = SDL_DisplayFormat( temp ); 		SDL_FreeSurface( temp ); 	}}

##### Share on other sites
Well, I've changed std::strings into const char*s but that didn't help... I've also been messing with the project settings and I've gotten rid of all the warnings... But it still won't run in open environ-release mode, and the problem is still in the same method. Does no-one here know what I should do? I've looked on these forums, and it seems like several people have had a similar problem of deployment, but none of the proposed solutions have worked for me...

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
627744
• Total Posts
2978895

• 10
• 10
• 21
• 14
• 14