0

I am in big big trouble. Please help. I have created a game for my client. It works fine when I run it from the Visual Studio 2008( in both release and debug configuration).

But when I run its stand alone exe (or making setup project) it does not work perfectly fine. It works but it does not work completely fine,and the problem is consistent(It shows the same problem every time, when I compile and run stand alone exe).

I had this problem in the past too but luckily I solved it.The way that problem was solved is very unusual:- Every thing was working perfectly fine and then I made some modifications in the code.The application started showing the same unusual behavior as described above.Then i started rolling back the modifications in the code one by one. The game started working perfectly fine when i removed a particular variable from a class and it uses.Then I checked all the C++ rules and every thing but found no issue in my implementation.Even every thing was working fine when i run from the Visual Studio. But I needed that variable and its uses in the game for some functionality of the game.So, that time I declared the variable in PUBLIC (previously it was a protected variable) and every thing worked perfectly fine.

I am very surprised to see this unusual behavior, whenever i declare the variable as PROTECTED there is problem but if I copy and paste in Public the problem is solved.(The variable is only being used in the Class where it is declared so there should not be any problem).

Please Help me I am again getting this unusual problem and not getting any solution this time.

Please tell me what may cause this problem. Thanks Tarun

user440607
  • 29
  • 1
  • 3

3 Answers3

3

If it happens outside the debugger, but not inside the debugger, you may be able to reproduce it using the _NO_DEBUG_HEAP environment variable, as described here (amongst other places): Link

Setting this variable should make the program running under the debugger behave more like the program running outside the debugger.

You can set environment variables in Visual Studio, so they affect only the debugged process: How do I set specific environment variables when debugging in Visual Studio?

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
  • I am unable to solve this problem. Please help me!!! How can I mimic the same condition as under the IDE. – user440607 Nov 15 '10 at 21:51
  • Did you try the above? Or attaching to process, as others suggested? Aside from those, it's hard to provide any specific suggestions. Fortunately while this sort of bug can be difficult to isolate the fix is usually very straightforward. –  Nov 16 '10 at 12:54
1

Changing the visibility of member variables can potentially change the layout of the class, since C++ only defines an ordering within visibility sections, not between them. Perhaps your change is breaking some code that isn't recompiled by your project.

Marcelo Cantos
  • 181,030
  • 38
  • 327
  • 365
0

I solved this problem. It was really very very hard to find the solution. I am writing here how to track this kind of bugs. Some steps you should try first:- 1) Dont ignore compiler warnings. Remove all types of warnings. 2) Program to write the states of the variable in a file in near the critical portion of your program where you are in doubt that is causing error. Write the states on each step. Examin the Variable, you may find some un initialize variables or improper type cast or comarison.

Conclusion: 1) Avoid any coparison (equal to comparison)with floating point values. 2) If you are making time based comparison, make sure you comapre that care fully. 3) Do not this Microsoft People are god.

user440607
  • 29
  • 1
  • 3