Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Game crashes when running the .exe


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 VisualChaser   Members   -  Reputation: 210

Like
0Likes
Like

Posted 22 December 2012 - 10:59 AM

I recently started translating a small platformer game from C# to C++ as a school project. The game works perfectly fine when I run it in debug and release mode in Visual C++, but when I run the .exe in the release folder it crashes after 1 second. It only shows a frozen image of the game and then instantly crashes. I copied the game data such as textures and music to the release folder so it's not missing any files. I figured out that it can't be caused by DirectX either because it shows all the textures, but frozen, so it's not getting through the update function. For sounds I'm using the FMOD library. I copied the dll into the release folder of the game and even tried removing the whole sound system from the game, but it's still crashing. Once again, everything works fine when I run the game inside Visual C++. Any idea what's causing the crash?



Sponsor:

#2 Stuntdk   Members   -  Reputation: 436

Like
0Likes
Like

Posted 23 December 2012 - 03:57 AM

From my experience this type of behaviour can occur from wrong use of SIMD XMVECTOR, XMMATRIX types<br />If you use those types in function calls or as datamembers of your class, you need to make sure they are properly aligned.<br /><br /><br />http://msdn.microsoft.com/en-us/library/windows/desktop/ee418725%28v=vs.85%29.aspx<br /><br />

#3 DarkRonin   Members   -  Reputation: 616

Like
0Likes
Like

Posted 23 December 2012 - 04:47 AM

You really need to write some error handling on all of your calls. Otherwise this is what happens.



#4 rip-off   Moderators   -  Reputation: 8685

Like
0Likes
Like

Posted 23 December 2012 - 12:02 PM

The game works perfectly fine when I run it in debug and release mode in Visual C++, but when I run the .exe in the release folder it crashes after 1 second. It only shows a frozen image of the game and then instantly crashes.
Does the Debug build crash in the same way when run outside of the IDE? You could also modify your Release profile (or copy it) to include the debug symbols, and then attempt to attach a debugger to the program after it has started.

I copied the game data such as textures and music to the release folder so it's not missing any files.
This is brittle. Keeping this in sync manually is tedious and error prone. Consider instead using the command line, or a batch file, to ensure the project directory is the current working directory. A simple debug.bat and/or release.bat in the project directory that calls Debug/Program.exe or Release/Program.exe respectively should suffice.

Also, consider temporarily deleting all your resources from the project directory (I presume you can retrieve them from version control). Ensure that when you run the program from the IDE, it (at least) correctly reports the file(s) it is missing, rather than crashing.

Edited by rip-off, 23 December 2012 - 12:04 PM.


#5 Steve_Segreto   Crossbones+   -  Reputation: 1551

Like
0Likes
Like

Posted 23 December 2012 - 02:01 PM

Also keep in mind that running in the IDE (debug or release) will initialize data to different values than just 0 - if you don't initialize the data yourself that is :)

 

However as pointed out, if you build your release version with symbols (pdb files), then you can launch the process using Visual Studio and debug from there. My guess is either un-initialized data behaving differently outside the IDE or a missing file resulting from your error-prone process of keeping the game assets in a different folder between IDE and explorer execution.



#6 VisualChaser   Members   -  Reputation: 210

Like
0Likes
Like

Posted 24 December 2012 - 02:30 AM

Sorry I forgot to mention that I do have error handling in all my initialize and load functions.
I still haven't found what's causing the crash. When I start the game I see all the objects and background but nothing moves, I even hear the background music, and then after 1 or 2 seconds I get the "Game.exe has stopped working" message. I tried to remove everything from FMOD from the game one more time, but that didn't help either.
The only thing I'm not sure about are the extern class variables. I'm defining new class variables in my main .cpp file, and defining external variables for them in the other .cpp files. This is correct right?
From my experience this type of behaviour can occur from wrong use of SIMD XMVECTOR, XMMATRIX types<br />If you use those types in function calls or as datamembers of your class, you need to make sure they are properly aligned.<br /><br /><br />http://msdn.microsoft.com/en-us/library/windows/desktop/ee418725%28v=vs.85%29.aspx<br /><br />
I'm not using those types. I only use D3DXVECTOR3 for the texture positions. Could this in any way cause my crash?

Does the Debug build crash in the same way when run outside of the IDE? You could also modify your Release profile (or copy it) to include the debug symbols, and then attempt to attach a debugger to the program after it has started.
Both debug and release mode work fine in the IDE, and they both crash when I run it outside of the IDE.
Also keep in mind that running in the IDE (debug or release) will initialize data to different values than just 0 - if you don't initialize the data yourself that is smile.png

However as pointed out, if you build your release version with symbols (pdb files), then you can launch the process using Visual Studio and debug from there. My guess is either un-initialized data behaving differently outside the IDE or a missing file resulting from your error-prone process of keeping the game assets in a different folder between IDE and explorer execution.
Visual C++ always gives errors or at least warnings for uninitialized data, or am I wrong?

EDIT:
I found the issue. It was a char variable for displaying scores that was defined as a new char twice. The debugger somehow ignored it but it caused the game to crash outside Visual C++.
Thanks for all the suggestions!

Edited by VisualChaser, 24 December 2012 - 03:45 AM.


#7 Steve_Segreto   Crossbones+   -  Reputation: 1551

Like
0Likes
Like

Posted 24 December 2012 - 09:20 PM

Visual C++ always gives errors or at least warnings for uninitialized data, or am I wrong?

 

Depends on warning level, I think level 4 turns those into errors.



#8 ~Helgon   Members   -  Reputation: 357

Like
0Likes
Like

Posted 25 December 2012 - 06:25 AM

Depends on warning level, I think level 4 turns those into errors.

 

I already can't compile in debug mode /W3 if variables were not initialized


from time to time i find time


#9 Steve_Segreto   Crossbones+   -  Reputation: 1551

Like
0Likes
Like

Posted 25 December 2012 - 12:26 PM

Steve_Segreto, on 24 Dec 2012 - 19:20, said:


Depends on warning level, I think level 4 turns those into errors.





I already can't compile in debug mode /W3 if variables were not initialized

 

Yeah I guess Visual Studio 2008 does it a bit different. I have two settings, Warning Level and Treat Warnings as Errors. I can compile and link no problem when I use an un-initialized variable under /W3 because it doesn't generate a warning. However YMMV with other Visual Studio versions.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS