Connecting Tech Pros Worldwide Forums | Help | Site Map

Problem only in release version!

babak
Guest
 
Posts: n/a
#1: Oct 10 '05
Hi everybody
I'm working with a project in embedded Visual Studio 4 and I have a
general problem which I hope that somebody can help me with. My problem
is the following:
My project works fine in debug version but behaves strangely and
sometimes crashes when I run it in release version. I suspect that it
is some sort of memory problem but it is not that easy to find out what
the problem exactly is (the project is rather big with maybe 30000
lines of code).
It should be the same code that runs in the both versions, right? Or is
there some part of the code in a project that might differ in debug and
release version?

Thanks for all your help.
Regards.
/Babak


Mirek Fidler
Guest
 
Posts: n/a
#2: Oct 10 '05

re: Problem only in release version!


babak wrote:[color=blue]
> Hi everybody
> I'm working with a project in embedded Visual Studio 4 and I have a
> general problem which I hope that somebody can help me with. My problem
> is the following:
> My project works fine in debug version but behaves strangely and
> sometimes crashes when I run it in release version.[/color]

That is nothing special. There is a bug that does not demonstrate itself
in debug version.

Actually, those are usually worst kinds of bugs - debugging release mode
is tricky :)

I suspect that it[color=blue]
> is some sort of memory problem but it is not that easy to find out what
> the problem exactly is (the project is rather big with maybe 30000
> lines of code).
> It should be the same code that runs in the both versions, right?[/color]

Unfortunately, no. Issued instruction seqences differ as differ many
other things, including memory allocation etc (debug mode usually has
some sort of improvement that detects allocation bugs).

Mirek
Maxim Yegorushkin
Guest
 
Posts: n/a
#3: Oct 10 '05

re: Problem only in release version!



babak wrote:[color=blue]
> Hi everybody
> I'm working with a project in embedded Visual Studio 4 and I have a
> general problem which I hope that somebody can help me with. My problem
> is the following:
> My project works fine in debug version but behaves strangely and
> sometimes crashes when I run it in release version. I suspect that it
> is some sort of memory problem but it is not that easy to find out what
> the problem exactly is (the project is rather big with maybe 30000
> lines of code).
> It should be the same code that runs in the both versions, right? Or is
> there some part of the code in a project that might differ in debug and
> release version?[/color]

M$ compilers initialize all variables with 0xcc in debug builds. In
release builds uninitialized variables have indeterminate value which
is often the source of the odd behaviour you observe. Check that you
initialize your variables before the first use.

Fraser Ross
Guest
 
Posts: n/a
#4: Oct 10 '05

re: Problem only in release version!



"Maxim Yegorushkin"[color=blue]
> M$ compilers initialize all variables with 0xcc in debug builds. In
> release builds uninitialized variables have indeterminate value which
> is often the source of the odd behaviour you observe. Check that you
> initialize your variables before the first use.
>[/color]

I would look for functions that don't return a value when they were
meant to as part of this checking.

Fraser.


John Harrison
Guest
 
Posts: n/a
#5: Oct 10 '05

re: Problem only in release version!


babak wrote:[color=blue]
> Hi everybody
> I'm working with a project in embedded Visual Studio 4 and I have a
> general problem which I hope that somebody can help me with. My problem
> is the following:
> My project works fine in debug version but behaves strangely and
> sometimes crashes when I run it in release version. I suspect that it
> is some sort of memory problem but it is not that easy to find out what
> the problem exactly is (the project is rather big with maybe 30000
> lines of code).[/color]

Most problems like this are caused by uninitialised variables.
[color=blue]
> It should be the same code that runs in the both versions, right? Or is
> there some part of the code in a project that might differ in debug and
> release version?[/color]

Plenty might differ, otherwise why would you have debug and release
versions?
[color=blue]
>
> Thanks for all your help.
> Regards.
> /Babak
>[/color]

john
Maxim Yegorushkin
Guest
 
Posts: n/a
#6: Oct 10 '05

re: Problem only in release version!



Fraser Ross wrote:[color=blue]
> "Maxim Yegorushkin"[color=green]
> > M$ compilers initialize all variables with 0xcc in debug builds. In
> > release builds uninitialized variables have indeterminate value which
> > is often the source of the odd behaviour you observe. Check that you
> > initialize your variables before the first use.
> >[/color]
>
> I would look for functions that don't return a value when they were
> meant to as part of this checking.[/color]

I'm not sure I got you. Do you mean "not all control paths return a
value" warning?

Fraser Ross
Guest
 
Posts: n/a
#7: Oct 10 '05

re: Problem only in release version!


> > > M$ compilers initialize all variables with 0xcc in debug builds.
In[color=blue][color=green][color=darkred]
> > > release builds uninitialized variables have indeterminate value[/color][/color][/color]
which[color=blue][color=green][color=darkred]
> > > is often the source of the odd behaviour you observe. Check that[/color][/color][/color]
you[color=blue][color=green][color=darkred]
> > > initialize your variables before the first use.
> > >[/color]
> >
> > I would look for functions that don't return a value when they were
> > meant to as part of this checking.[/color]
>
> I'm not sure I got you. Do you mean "not all control paths return a
> value" warning?
>[/color]

Yes there should be a compiler warning. If an object is initialised to
0xCC or 0 or whatever in debug mode before being given a value from a
function that doesn't return anything the object will always have 0xCC
in debug mode and anything in release mode. I had a bug like this
recently. I don't think I got a warning message.

Fraser.


Jay Nabonne
Guest
 
Posts: n/a
#8: Oct 10 '05

re: Problem only in release version!


On Mon, 10 Oct 2005 08:15:21 -0700, babak wrote:
[color=blue]
> Hi everybody
> I'm working with a project in embedded Visual Studio 4 and I have a
> general problem which I hope that somebody can help me with. My problem
> is the following:
> My project works fine in debug version but behaves strangely and
> sometimes crashes when I run it in release version. I suspect that it
> is some sort of memory problem but it is not that easy to find out what
> the problem exactly is (the project is rather big with maybe 30000
> lines of code).
> It should be the same code that runs in the both versions, right? Or is
> there some part of the code in a project that might differ in debug and
> release version?
>[/color]

In addition to the rest, make sure you don't have valid code inside an
"assert". Asserts go away when compiled for release.

For example:

assert(CodeIReallyNeedInAllBuilds());

is bad, because in release build, the function will not be called.

- Jay

babak
Guest
 
Posts: n/a
#9: Oct 11 '05

re: Problem only in release version!


Hi everybody
Thanks for all your replies and help. The problem for me now is to find
out where in the code I might have uninitialized variables or functions
that don't return a value when they are supposed to. As i said before,
it a huge project I'm running so it could be pretty time consuming :(

Regards.
/Babak

Karl Heinz Buchegger
Guest
 
Posts: n/a
#10: Oct 11 '05

re: Problem only in release version!


babak wrote:[color=blue]
>
> Hi everybody
> Thanks for all your replies and help. The problem for me now is to find
> out where in the code I might have uninitialized variables or functions
> that don't return a value when they are supposed to. As i said before,
> it a huge project I'm running so it could be pretty time consuming :(
>[/color]

Good luck.
This is why 'testing during development' and 'development in small
steps' is soooooo important.

If you can, divide the whole project into smaller subprojects and
write test code for the subprojects.

--
Karl Heinz Buchegger
kbuchegg@gascad.at
Closed Thread


Similar C / C++ bytes