Debug .exe differs from compiled run

Started by
4 comments, last by doeme 11 years, 2 months ago

Any idea why when I run my program from the vc++ 2008 compiler I'm getting a different output than if I run the .exe from the debug dir. Been working on this program for a couple years and they've always been the same then suddenly they are different. In one version I have an army of guys attacking another army, works fine when ran from the compiler, in the .exe version one entire army does not appear? I can't easily go back to a last saved version (I keep many) as I didn't notice this until about 2 weeks or more of work has been added... I just didn't notice, didn't run this test, was working on menus and other stuff...

I've double and triple checked that I am running the same .exe that is being compiled, I purposefully added in an error to one of the buttons, and sure enough they are the same... kinda scratching my head on where to start on this one, my gut feel is that an array is being written beyond it's limit, but since everything works fine in the compiled version kinda hard to debug...

Thoughts?

Thanks,

rhuala

Advertisement

Yeah, my guess would be something like array overruns or underruns on a stack array or something. I'd suggest:

1. See if you can repro it on an optimised build in the debugger.

2. I believe it's possible to attach the msvc debugger to a process that's already running.

3. printf debugging (I guess you'll need to print out to a file)

2 things I'd check (in addition to the array problem mentioned):

1) Check your directory structure. Does the relative directory "../" access the same folder from both your .exe and visual studio project (they can be different).

2) Does the app run alot faster from your .exe than from the project? In this case, are you scaling scene movement by the application speed? If your not then your scene objects may just be moving very far very quickly.

This might be caused by variables or objects that are not initialized properly. These kind of bugs can be very hard to find if you do not have a clue where to start.

I'm guessing you are if running the exe from Visual Studio you are running it with the debugger enabled and in debug mode which might cause uninitialized memory to be set to a certain value. Check if the program behaves the same if run from VS without the debugger (CTRL+F5) or if your army goes missing as well.

As C0lumbo said, late attaching the debugger might help, as well as some logging.

I can't easily go back to a last saved version (I keep many) as I didn't notice this until about 2 weeks or more of work has been added... I just didn't notice, didn't run this test, was working on menus and other stuff...

This sounds like you don't use any versioning software like SVN, my advice here is to start using something to track your changes better. Even if it's only running locally on your machine.

Yeah, my guess would be something like array overruns or underruns on a stack array or something. I'd suggest:

1. See if you can repro it on an optimised build in the debugger.

2. I believe it's possible to attach the msvc debugger to a process that's already running.

3. printf debugging (I guess you'll need to print out to a file)

So how do I do #1 and #2? Especially #2

C0lumbo, on 11 Feb 2013 - 08:53, said:

Yeah, my guess would be something like array overruns or underruns on a stack array or something. I'd suggest:



1. See if you can repro it on an optimised build in the debugger.

2. I believe it's possible to attach the msvc debugger to a process that's already running.

3. printf debugging (I guess you'll need to print out to a file)



So how do I do #1 and #2? Especially #2

For #1: Build your solution/project in release mode and start it again from the visual studio. Depending on your configuration the release-mode might be called differntly. Just pick any mode which has no debug-information compiled and code-optimisation enabled.

For #2: You can debug any running process from Visual Studio over the menu "Debug" -> "Attach to Process"; However this has some pitfalls as well. See this article here (just the first one that came up on google) or Google it

This topic is closed to new replies.

Advertisement