I'm using Visual Studio 2012 Express for Desktop and I have a code based on Winsock client-server. The problem comes when running the program. One functionality of the program works ONLY when debugging. Why could it happen? Any help is appreciated.
1 Answer
For Visual Studio, if you compiled using the usual debugging defaults, there are things that are done at runtime that are not done in release mode.
One is that variables are initialized to 0 (or their default), while release mode they are left uninitialized. So it could be that uninitialized variable(s) are being used, and you don't see the issue when running the debug version.
Your best bet is to debug the release version. Then you can use the integrated debugger in the release build of your application.
12 Comments
PaulMcKenzie
No you don't need to change the compiler version. Just rebuild the release version with debug symbols. As a matter of fact, you should be doing this anyway (you should have produced a .PDB file necessary to do debugging). Also, you should have asked yourself "what if there is a bug reproducible on the server and only on the server?" What do you do then? There is remote debugging, creating crash dumps and debugging the crash dump in Visual Studio, etc. Once you push your program to other machines / servers / environments, these issues should have been taken into consideration.
euskadi
I've tried debugging the code in the release version, but the problem remains. There is no debug error, no crashes. It is just that I'm expecting to receive , for example, 4 messages of 2 different users, and when running the release version, it just prints 2 of them (of a single user). When debugging (also tried the release version), it works perfectly. @PaulMcKenzie
PaulMcKenzie
@Zarauztarra Well, since it doesn't crash, then one of the basics doesn't seem to have been covered. It is to create log files. Yes, a simple log file showing exactly what is being done, what the values are, etc. are essential on programs such as this. All you would have needed was to look at the log files and ascertain from that the information you need. Again, one of the things any good program that is to be released on other machines needs to do, and that is a log of what is being done.
PaulMcKenzie
I know that you may be desperate, but I believe it would be much easier if you took your program, and wrote to a log file all of the variables that are important in the part of the program that is the problem. If the first cut doesn't do it, add more logging statements to whittle down the problem until you see that a variable (or variables) are not set, or a value is not correct, etc. I can't be a full-time consultant.
|