Edited by StoneMask, 16 October 2012 - 08:49 AM.
What makes Debug different from Release?
#1 Members - Reputation: 209
Posted 16 October 2012 - 08:37 AM
#3 Members - Reputation: 246
Posted 16 October 2012 - 09:05 AM
I would suggest going into Debug mode and stepping through your code to find where the problem is.
Edited by littletray26, 16 October 2012 - 09:06 AM.
They just see the big blue 'e' and think "Internet". The thought process usually does not get much deeper than that.
Worms are the weirdest and nicest creatures, and will one day prove themselves to the world.
I love the word Clicky
#4 Crossbones+ - Reputation: 924
Posted 16 October 2012 - 10:26 AM
Just out of curiosity, did your VS set you to debugging in Release by default?
Regards,
Stitchs.
#5 Members - Reputation: 466
Posted 16 October 2012 - 11:01 AM
Edited by UltimaX, 16 October 2012 - 11:02 AM.
#6 Moderators - Reputation: 2288
Posted 16 October 2012 - 11:12 AM
"Debug" and "Release" are idioms of Visual Studio (and many other IDEs) -- they are the names of default build configurations generated for a solution/project/whatever-your-IDE-calls-it. Generally, the "debug" configuration does no optimization and enables a bunch of extra sanity checking and safety mechanisms that are not present in the "release" configuration (which also enables optimizations). Almost all of the options in the configuration correspond directly to parameters that can be given to the compiler and linker and any other tools used to actually build your project.
Every major IDE that supports these kinds of configurations also allows you to modify them as you need to, and usually to define additional ones as well.
Josh Petrie | Lead Tools Engineer, ArenaNet | Microsoft C++ MVP
#7 Members - Reputation: 896
Posted 17 October 2012 - 05:57 AM
STLport | Lua | Squirrel | Doxygen | NASM | bochs | osdev | Ruby | FreeBSD | Zend Framework 2 | YUI 3 | VP UML| ZFS | Linux Mint (Cinnamon)
#8 Members - Reputation: 209
Posted 18 October 2012 - 10:31 AM
Just out of curiosity, did your VS set you to debugging in Release by default?
No, I recently made a topic asking how to ship out a usable .exe, and they told me that I should build in release configuration. So instead of switching back all the time, I just got lazy and left it on Release. I have learned the error of my ways...
Thanks for the information everybody! If I have any other questions, I'll be sure to come back to this thread.
Baby, make your move, step across the line,
touch me one more time, come on, dare me! I wanna take you on, I know I can't lose,
#9 Members - Reputation: 209
Posted 23 December 2012 - 10:07 PM
So I made sure I was always set to Debug mode after this thread, and so far I haven't had any errors. But then I switched to Release to test something out, and now everything has been thrown into chaos again. Things are being drawn out of order, my functions are being called with the wrong parameters-- everything is out of whack. If I can't trust Debug mode to get rid of these things, then how will I know nothign will go wrong with different computers and settings? Do I just have to keep switching in between them and making sure both modes run correctly? What is happening? Why is it so drastically different to run in Release mode?
Baby, make your move, step across the line,
touch me one more time, come on, dare me! I wanna take you on, I know I can't lose,
#10 Crossbones+ - Reputation: 1374
Posted 23 December 2012 - 10:13 PM
In release mode, it creates a separate file (Called Release) for your project. You have to re-link Release Mode for it to work and include your Library DLL's and Files. I had your same problem with my first game (Pong
!).
Here's Breakout:
Breakout!
If you need some photo editing done, contact me:
superman3275@gmail.com
if you want some programming help, or are recruiting for a game development team, either PM me on here or email me up there
#11 Members - Reputation: 1308
Posted 24 December 2012 - 12:55 AM
So I made sure I was always set to Debug mode after this thread, and so far I haven't had any errors. But then I switched to Release to test something out, and now everything has been thrown into chaos again.
Which generally means that you still have some major bugs in your code and are simply lucky that those bugs don't have any visible consequences in debug mode, either because your data has a different and less tightly packed memory layout or because stuff is being initialized for you.
The most important lesson in programming: just because it compiles, doesn't mean it's working and just because it appears to be working, doesn't mean it isn't full of serious bugs. Especially when it comes to C/C++, "trial and error coding" will bite you and you should be knowing what you're doing every step along the way. Never "try" something and decide that if it doesn't crash right away it must be "correct" to do it that way.
If your bugs don't show in a debug build and a release build is too optimized or lacking debug symbols to be useful, you will want to copy your release configuration and change the settings, hopefully finding one where the bugs are still happening and you can decently debug. Otherwise, there is always caveman debugging, where you spam debug outputs all over the place to figure out where things are going wrong.
As for "how I can be sure it will work on other computers". That's why "testing" is a very complex subject of its own, involving unit tests, black/white box tests, regression tests and all kinds of other test strategies. Essentially writing tests will take up about the same amount of time as writing the actual code (at least if you want to do it "right").
#12 Members - Reputation: 1230
Posted 24 December 2012 - 04:41 AM
The checks are usually pretty basic, and if you for example use a pointer to modify memory, there is no check that that memory is actually allocated (and it can't know if it points to the data you think it points too)
There might be a check of the heap integrity the next time you allocate or free, but if you also have problems with leaks and how you allocate your memory, maybe this check never is run.
And if you allocate it on the stack, all things of wonderfully weird things can happen if you write outside your allocated area. On some platforms you might even change what line of code you return to at the end of your function...
These things are really just possible to get rid of with diligence, keeping the lifetime and ownership of your objects clearly defined, make sure all variables are initialized before you use them, and make sure pointers never point to uninitialized or deleted data or walks past the bounds of an array.
Edited by Olof Hedman, 24 December 2012 - 04:42 AM.
#13 Members - Reputation: 1589
Posted 24 December 2012 - 05:43 AM
And if you allocate it on the stack, all things of wonderfully weird things can happen if you write outside your allocated area. On some platforms you might even change what line of code you return to at the end of your function...
You know I was just thinking yesterday that an array on the stack could do that with the correct negative index. That kind of thing makes me chuckle. (As you can see from my sig.)
There are ten kinds of people in this world: those who understand binary and those who don't.
#14 Members - Reputation: 209
Posted 24 December 2012 - 02:04 PM
Well, the "platform" I'm using is the command prompt. Pretty much, my enemies don't write the "enemy" character to the array, but a bunch of garbage values that coincide with character values. So if I ever intersect with the enemies, sometimes their character value is equal to something else my character is supposed to interact with, so it'll make me enter a sort of bizarre black and white version of the normal dungeon that's generated, or it'll send me back into the same dungeon, which increases my difficulty level and regenerates the dungeon, so say I'm running towards an exit. Sometimes intersecting where an enemy object is will regenerate the dungeon, so I end up just running into a wall. It's kind of terrifying, kind of weird, but it's kind of cool at the same time. But eventually the enemy will touch me with a character that just changes my world setting to the overworld, so I'm stuck in a dungeon that behaves like the overworld, which is more boring. I'll post a video, probably.
I've isolated the problem to just my enemy objects. They're contained in a vector array of pointers to enemy objects. Without the enemies everything runs fairly well. I think that Trienco's "know what you're doing" advice is pretty good. Admittedly, I'm a bit weak in my knowledge about pointers.
Baby, make your move, step across the line,
touch me one more time, come on, dare me! I wanna take you on, I know I can't lose,
#15 Members - Reputation: 3717
Posted 24 December 2012 - 02:26 PM
Edit: Whats wrong with the quoting ?
Edited by SimonForsman, 24 December 2012 - 02:27 PM.
The voices in my head may not be real, but they have some good ideas!
#16 Members - Reputation: 1589
Posted 24 December 2012 - 10:02 PM
<blockquote class="ipsBlockquote" data-author="StoneMask" data-cid="5014010"><p>Well, the "platform" I'm using is the command prompt. Pretty much, my enemies don't write the "enemy" character to the array, but a bunch of garbage values that coincide with character values. So if I ever intersect with the enemies, sometimes their character value is equal to something else my character is supposed to interact with, so it'll make me enter a sort of bizarre black and white version of the normal dungeon that's generated, or it'll send me back into the same dungeon, which increases my difficulty level and regenerates the dungeon, so say I'm running towards an exit. Sometimes intersecting where an enemy object is will regenerate the dungeon, so I end up just running into a wall. It's kind of terrifying, kind of weird, but it's kind of cool at the same time. But eventually the enemy will touch me with a character that just changes my world setting to the overworld, so I'm stuck in a dungeon that behaves like the overworld, which is more boring. I'll post a video, probably.<br /> <br />I've isolated the problem to just my enemy objects. They're contained in a vector array of pointers to enemy objects. Without the enemies everything runs fairly well. I think that Trienco's "know what you're doing" advice is pretty good. Admittedly, I'm a bit weak in my knowledge about pointers.</p></blockquote><br />As a rule of thumb in C++ , do not use raw pointers unless you have a really good reason to do so, any object you have that deals with raw pointers must follow the rule of three and you always have to be careful when using the pointers. (It sounds as if your enemy objects are writing to memory that belongs to other objects).<br /><br />If you post the code for your enemy class (and its subclasses) i'm sure we can figure out where you are going wrong.
Edit: Whats wrong with the quoting ?
You broke the internet. Merry Christmas. ![]()
There are ten kinds of people in this world: those who understand binary and those who don't.
#17 Members - Reputation: 209
Posted 26 December 2012 - 03:04 PM
lol
So I discovered the problem, kind of? It really didn't have anything to do with the way I was storing memory or anything. For some reason, the function I use to spawn the enemies and place them in an empty spot were, for some reason, placing them on top of collision blocks. I didn't program them to do anything when they're stuck in a collision block, but for some reason, they flip out and start teleporting me places.
Baby, make your move, step across the line,
touch me one more time, come on, dare me! I wanna take you on, I know I can't lose,
#18 Members - Reputation: 344
Posted 26 December 2012 - 03:13 PM
lol
So I discovered the problem, kind of? It really didn't have anything to do with the way I was storing memory or anything. For some reason, the function I use to spawn the enemies and place them in an empty spot were, for some reason, placing them on top of collision blocks. I didn't program them to do anything when they're stuck in a collision block, but for some reason, they flip out and start teleporting me places.
You mean you didn't think you did. Unless you're using someone else's code it is entirely likely and most likely true that you wrote something that is having an unintended consequence.
Short version: You probably did program them that way.
#19 Members - Reputation: 1954
Posted 26 December 2012 - 04:12 PM
I.e. The most common value in RAM is zero. So if you forget to NULL a pointer that should be NULL initially then often it will just work. So along come the Debug runtimes which initialise all your locals to 0xCC. Next up you have a bool variable which is supposed to be initialised to true, except that you forgot. Now under debug that will always act as if it were true initially since it is not zero. Switch back to release and then boom it starts out false most of the time.
Long story short, yeah you really do need to switch back and forth and check both from time to time. A good idea is to use a version control system and make sure that both debug and release builds are working each time before you check in the bit you were working on, or before merging it to the main branch or whatever. It's always good to have a working debug and release build version that you can compare with. But other than that, the rest of the time you can probably just use debug builds.
Edited by iMalc, 26 December 2012 - 04:13 PM.
My website dedicated to sorting algorithms
#20 Crossbones+ - Reputation: 5188
Posted 26 December 2012 - 05:37 PM
Long story short, yeah you really do need to switch back and forth and check both from time to time.
As the only developer on my own engine I switch constantly, but I have noticed a trend in the professional world in which all developers on all teams in all companies in which I have worked build exclusively in debug mode for very extended periods of time, sometimes not checking release mode at all for up to 6 months. One project here had been going for about 9 months and since optimization is my job I asked the leader, “So how does it run in release mode?”, to which he replied, “We’ve never run it in release mode.”
That is why at my office I work almost exclusively in release mode, because as you say it is important for both to be tested constantly, and it seems no one else is going to do it.
L. Spiro
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums






