Thread: No errors when debugging?

  1. #16
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    cpjust, can you vouch for the VS development team and summarize why they do this? Or is this common in other debuggers? To me it seems like they're saying "If you make mistakes when it doesn't matter (debug build), its OK we're protecting you. If you make mistakes when it does matter (release build) you're screwed."

    Of course when releasing software, our job is to sufficiently test it, and not rely on a compiler/debugger saying it works or not. But isn't, by the debug mode being less strict, just adding to the potential for errors slipping through?

    EDIT: I just wanted to clarify I'm not anti-Microsoft (though not necessarily pro-Microsoft), so it isn't about just trying to point them out. VS is an unbelievably good piece of software.
    Last edited by nadroj; 03-06-2010 at 11:55 PM.

  2. #17
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    VS adds 4 extra bytes of padding before and after your variables; so if you write a few bytes past the end of an array it won`t corrupt other variables the way it does in release mode.
    Then how would that affect pointers to memory on the heap? Not sure how bad pointers to addresses on the heap could cause stack corruption. And if the program causes stack corruption a dialog box will be displayed stating as much when the program is run.

    You can get away with more in debug mode as well even with allocations on the heap b/c the debug CRT puts a lot more information before each block - not sure if it puts any information following the memory block. But this means the prior block could overwrite quite a bit of the next block's information without causing problems...that is until the next block is cleaned up at which point b/c the information in the debug block header is corrupt the heap will become corrupted. This would most likely happen when the block with corrupted debug header information was deleted.
    Last edited by VirtualAce; 03-07-2010 at 12:41 AM.

  3. #18
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by nadroj View Post
    cpjust, can you vouch for the VS development team and summarize why they do this? Or is this common in other debuggers? To me it seems like they're saying "If you make mistakes when it doesn't matter (debug build), its OK we're protecting you. If you make mistakes when it does matter (release build) you're screwed."

    Of course when releasing software, our job is to sufficiently test it, and not rely on a compiler/debugger saying it works or not. But isn't, by the debug mode being less strict, just adding to the potential for errors slipping through?

    EDIT: I just wanted to clarify I'm not anti-Microsoft (though not necessarily pro-Microsoft), so it isn't about just trying to point them out. VS is an unbelievably good piece of software.
    I believe they do that to make it easier to detect stack corruption, since you can then look at the memory and see if those 0xCDCDCDCD bytes change. But yes, it can make bugs less apparent if you don't know what you're looking for.

    Quote Originally Posted by Bubba View Post
    Then how would that affect pointers to memory on the heap? Not sure how bad pointers to addresses on the heap could cause stack corruption. And if the program causes stack corruption a dialog box will be displayed stating as much when the program is run.
    I never said it did affect heap memory. I have no idea what nadroj's program is doing, so I thought he might have some arrays that were being overflowed.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  4. #19
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    Quote Originally Posted by cpjust View Post
    I have no idea what nadroj's program is doing, so I thought he might have some arrays that were being overflowed.
    I have no clue what my program is doing either... I never wrote one! You probably meant yaya's.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sneaky little linker errors...
    By Tozar in forum C++ Programming
    Replies: 8
    Last Post: 10-25-2006, 05:40 AM
  2. Errors with header files in OpenGL using VisualC++
    By wile_spice in forum Game Programming
    Replies: 3
    Last Post: 06-22-2006, 08:56 AM
  3. Program Fatal Error- Please Explain
    By luckygold6 in forum C++ Programming
    Replies: 9
    Last Post: 03-06-2003, 08:56 PM
  4. executing errors
    By s0ul2squeeze in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2002, 01:43 PM