[ODE] Compiling as Release differs from Debug

SJS ode at pulsecode.net
Wed Dec 3 21:50:57 MST 2003


As Steve Baker said, the problem is probably not ODE, but--

  Don't be too hard on MSVC-- in debug mode uninitialized memory (including
variables) are set to '0xCCCCCCCC' or a similar value.  This is so when you
use an uninitialized pointer you'll usually get an access violation in debug
mode (and the debugger will let you see the '0xCCCCCCCC', letting you know
it was uninitialized).  The downside is, like the other Steve said, release
differs.
  The bugs that slip through are usually the OPPOSITE of what you might
think-- in Release, uninitialized memory is not guaranteed to have any
particular value (for the sake of speed), but the memory is often zero
already, so an uninitialized pointer is often 'NULL' (0x00000000), where in
debug it was 0xCCCCCCCC.

Anyway, look for uninitialized (0xCCCCCCCC) pointers in your Debug build
(particularly in cases where you're checking if a pointer is NULL).

In rare cases, you might find that turning off particular optimizations in
the compiler fixes the problem (see Project/Settings/C-C++/Optimizations),
but this is rare and is often due to a very strange piece of code that fools
coders as well as compilers.

Another note: you'll sometimes see values like '0xCDCDCDCD', '0xFEFEFEFE',
and '0xbaadf00d' (yes, funny funny programmers) that are similar markers
used by various memory management routines in debug builds.


Steve Schlueter

-----Original Message-----
From: ode-bounces at q12.org [mailto:ode-bounces at q12.org]On Behalf Of Steve
Baker
Sent: Wednesday, December 03, 2003 8:19 PM
To: garry; ode
Subject: Re: [ODE] Compiling as Release differs from Debug


garry wrote:
> I don't know whether this is down to me being a rubbish programmer or
> not. But here's the situation.
>
> When I compile my game in debug mode it works great. But when I compile
> it in release mode it's really buggy.

This must be MSVC - right?

For some *insane* reason, the developers of MSVC decided that in debug mode,
all variables would be pre-initialised to zero if no otherwise initialised
by the program.  But in released code, this is not the case.

So, uninitialised variable bugs are hard to find in debug mode - but show up
quite well in release mode.  Hence, the debug mode does a really good job of
hiding the very bugs you'd hope it would help you find.  What *were* they
thinking when they did that?

This isn't the only difference in the way code is compiled between debug and
release modes - there are many others.

Microsoft software is really, truly and utterly a pile of shit.

> Is this a common problem? I did a search on google but only found one
> post about it and it wasn't answered.

Yes - it's very common problem.

It's nothing unique to ODE though - so it probably doesn't belong on this
mailing list.

---------------------------- Steve Baker -------------------------
HomeEmail: <sjbaker1 at airmail.net>    WorkEmail: <sjbaker at link.com>
HomePage : http://www.sjbaker.org
Projects : http://plib.sf.net    http://tuxaqfh.sf.net
            http://tuxkart.sf.net http://prettypoly.sf.net
-----BEGIN GEEK CODE BLOCK-----
GCS d-- s:+ a+ C++++$ UL+++$ P--- L++++$ E--- W+++ N o+ K? w--- !O M-
V-- PS++ PE- Y-- PGP-- t+ 5 X R+++ tv b++ DI++ D G+ e++ h--(-) r+++ y++++
-----END GEEK CODE BLOCK-----

_______________________________________________
ODE mailing list
ODE at q12.org
http://q12.org/mailman/listinfo/ode




More information about the ODE mailing list