• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
StoneMask

What makes Debug different from Release?

20 posts in this topic

I've been working on a project for awhile, and since I often send the executables to my friends to test, I tend to debug in Release mode. But I changed it back to Debug, and suddenly, a bunch of stuff is going wrong. How much different can it be that it pretty much destroys the data in my arrays? I'm using Microsoft Visual Studios 2010 Express, and when I switch to Debug from Release, at a certain point in my code, one of my two dimensional character arrays becomes half filled with a special character I use to test for collisions. I don't think it's necessary to show my code. I don't want to find where I specifically went wrong, just what makes Debug have this dramatic of a difference. Edited by StoneMask
1

Share this post


Link to post
Share on other sites
When you're in Release mode you're sacrificing a lot of the runtime debugging Visual Studio does. In reality, however, your array is trashed in both Debug and Release mode. In Release mode you just can't tell because you're not debugging it! [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img]

I would suggest going into Debug mode and stepping through your code to find where the problem is. Edited by littletray26
1

Share this post


Link to post
Share on other sites
Just a little addition as I don't think much more can be added; It is always best to code + build in debug mode as this helps to iron out as many potential bugs your program has, before you set it to compile in Release. Release building is for (hence the name) deployment of your product to the client.

Just out of curiosity, did your VS set you to debugging in Release by default?

Regards,

Stitchs.
1

Share this post


Link to post
Share on other sites
In addition, "Debug" configurations most often compile full symbols into your executable, allowing you to easily debug runtime errors "just in time". There's also the option of creating external symbol database files for "Release" mode executables; however, optimized executables often reorder, alias, and/or eliminate code and data, and the symbols and code representation may not be accurate or readable anymore in that case.
0

Share this post


Link to post
Share on other sites
[quote name='stitchs' timestamp='1350404800' post='4990784']Just out of curiosity, did your VS set you to debugging in Release by default?[/quote]

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.
1

Share this post


Link to post
Share on other sites

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?

0

Share this post


Link to post
Share on other sites

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 :)!).

0

Share this post


Link to post
Share on other sites
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").

1

Share this post


Link to post
Share on other sites
It's impossible for debug mode to catch all crazy things a human programmer can think of doing.
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
1

Share this post


Link to post
Share on other sites
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.)

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites
<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 ? Edited by SimonForsman
0

Share this post


Link to post
Share on other sites
<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. laugh.png

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites
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.

1

Share this post


Link to post
Share on other sites
The unfortunate thing is the the stuff that the debug build does for you to catch problems like using uninitialised variables, sometimes is also specifically what causes you to not find problems like using uninitialised variables.

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
1

Share this post


Link to post
Share on other sites
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

0

Share this post


Link to post
Share on other sites

Just to be clear on this issue, there's not actually anything that's inherently different between "Debug" and "Release". They're just 2 default configurations added to your project by Visual Studio, and by default they're configured such that Debug has optimizations off with debugging features enabled, while Release has has optimizations on with most debugging features disabled. In practice you're free to change the various settings however you want for each configuration, or even create new ones with arbitrary names. Where I work actually use more than just 2 configurations, with various things like optimizations, debug utilities, and asserts turned on and off depending on our needs. So for instance on my team we usually run most of our tools and build system with optimizations on (so it's not slow), but with asserts on so that we know when something goes wrong. Then when we push a build for artists and designers we use a configuration with asserts off.

1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0