Different behaviour in release vs. debug 
Author Message
 Different behaviour in release vs. debug

I have a program which I originally wrote and compiled under Windows 2000.
It makes use of the TrackMouseEvent() function, and in order to link this
in, I have

#define _WIN32_WINNT 0x0400

Under Windows 2000 the program runs smoothly. When I move it to a Windows 98
machine, however, the release version explodes with an "Invalid Page Fault"
as soon as the message produces by TrackMouseEvent goes off. I can't tell
exactly where it's dying, since I don't have the debugging information. The
debug version runs fine in precisely the same environment. I tried omitting
the above line, but then it won't define TrackMouseEvent or the related
messages, etc.
Does anyone know why this might happen? It makes me nervous, like there's
also something wrong with the debug version, but the behaviour is masked by
the debugging behaviour.
Thanks.

Douglas Conrey



Sun, 13 Oct 2002 03:00:00 GMT  
 Different behaviour in release vs. debug
Greets,

    It sounds as if you may be using this correctly.  If the problem occurs
when the message is received, it could be a problem in code that is run when
a message received is being handled.  (I am assuming you're not opting to
have the structure filled in for you from the call.)

    In debug versions, certain uninitialized items are set to 'magic'
numbers in order to make uninitialized items more visible.  It is possible
that something (perhaps a pointer) is not being initialized before being
used and perhaps even passed to an API function somewhere along the line.  I
also would not be surprised if an exception which is not handled by Windows
98 is possibly more gracefully handled by Windows 2000.  However, it is
difficult to tell.

Regards,

Joe


Quote:
> I have a program which I originally wrote and compiled under Windows 2000.
> It makes use of the TrackMouseEvent() function, and in order to link this
> in, I have

> #define _WIN32_WINNT 0x0400

> Under Windows 2000 the program runs smoothly. When I move it to a Windows
98
> machine, however, the release version explodes with an "Invalid Page
Fault"
> as soon as the message produces by TrackMouseEvent goes off. I can't tell
> exactly where it's dying, since I don't have the debugging information.
The
> debug version runs fine in precisely the same environment. I tried
omitting
> the above line, but then it won't define TrackMouseEvent or the related
> messages, etc.
> Does anyone know why this might happen? It makes me nervous, like there's
> also something wrong with the debug version, but the behaviour is masked
by
> the debugging behaviour.
> Thanks.

> Douglas Conrey



Sun, 13 Oct 2002 03:00:00 GMT  
 Different behaviour in release vs. debug


<debug seems to work, release fails>

There are differences between debug and release.
Debug information provides a "pad" that can mask
errors because the mistake can occasionally only
affect the debug info.  And release involves the
optimizer which can move stuff around in ways you
may not expect.

If you use assert (and you should) look for doing
stuff that you should not.

ASSERT( i == 0)

is fine,

ASSERT( i++ == 0)

is not.

Look for improperly initialized variables, especially
pointers.

Look for off-the-end errors where you walk off an
array or linked list, either end.  Think about not
using arrays or linked lists, but use STL containers
instead.

Look for places where you depend on things being in
memory in a particular order.  Especially look for
strings that may get moved by optimization. If you
have "Error!" in two places in the code, you may
only get one instance after optimization, and that
may not be close to the rest of the code near either
original instance.

Use the divide-and-conquer method. In a copy of your
project, take out half the code. If the bug stays,
take out half of the remaining. If the bug goes away,
keep the other half.  Keep doing this till you find
the specific chunk of code that has the problem.
Also, splitting the code this way can make the bug change
it's specific manifestation, and so make it easier to spot.

Use brute force debugging.  Put in printf statements
or fprintf statements that record where the program
has gotten to. Or use message boxes.

Long term, use the de{*filter*} to step through new code
as soon as you type it in.  Look at every variable
and make sure it is doing exactly what you expected.
Use the de{*filter*} to exercise every loop in your code,
especially rarely used error handling routines.

Also, get the book _C++ FAQs (Second Edition)_ by
Cline et al. Chapters 9 and 10 are especially relevant.

--
Dan Evens
Standard disclaimers etc. No spam please.



Mon, 14 Oct 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. _msize behaviour different in release and debug builds

2. Different return valus in Debug vs Release Build

3. Different debug vs release version

4. ON_MESSAGE in threads: Debug vs Release different?

5. Code which produced different behaviour on different machines

6. Structure is different in debug/release

7. Different execution between Release and Debug version

8. Structure is different in debug/release

9. different results between Debug/Release builds

10. different debug-release results

11. sin(x) different debug&release-results

12. Structure is different in debug/release

 

 
Powered by phpBB® Forum Software