Re: Release version crashes - again

From: Bruce Eitman \(eMVP\) (beitmannospam_at_NOSPAM_applieddata.NOSPAM_net)
Date: 09/15/04


Date: Wed, 15 Sep 2004 11:35:56 -0400

I would take a look at any assumptions about the values of variables prior
to them being initialized.

For example

DWORD * pointer;
and
DWORD *pointer = NULL;

are not usually equal in retail, but they usually are in debug. So code
that does

if( pointer == NULL)
    initPointer( pointer );

will execute initPointer in debug, but might not in retail. The solution is
to always explicitly init varialbles somehow, someplace prior to reading
them. One quick way to test this, is to set a compiler/linker flag that
causes all variables to be cleared by default (which is what usually happens
in debug) I don't know off the top of my head what the flag is.

-- 
Bruce Eitman (eMVP)
Senior Engineer
beitman AT applieddata DOT net
Applied Data Systems
 www.applieddata.net
An ISO 9001:2000 Registered Company
Microsoft WEP Gold-level Member
Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups?  Let us know!
https://www.windowsembeddedeval.com/community/newsgroups
"Charles Gilley" <cgilley@bravesw.com> wrote in message
news:de3cdf0.0409150636.14c89f51@posting.google.com...
> Okay, I've read all of the assorted notes for this issue, and I'm
> still beating my head against the wall, and I'm about ready to find
> another career.
>
> The program works fine in debug, and it C0000005's in release mode.
> Yes, I know this means something didn't get initialized.  I need some
> suggestions for tracking the thing down.
>
> In release mode, nothing works in terms of printing.  DEBUG, TRACE,
> etc.  all evaluate to zero, besides there isn't a debugger window to
> send it to. Hmmm.
>
> Read an article on using UDP to broadcast the print debug: this is a
> GREAT idea, but my code is crashing in the CONSTRUCTOR area (long
> story about this), so I cannot even get to the point of getting the
> UDP broadcast operational.
>
> I have Entrek's CodeSnitch.  Good product, but it isn't finding
> anything in debug mode.
>
> The map of the image provides next to nothing in terms of information.
>
> AfxMessageBox - doesn't work because nothing is set up this early in
> the application launch process.
>
> I'm running out of ideas... anyone have any tricks or suggestions to
> isolate this SOB?
>
> Constructor: The way this code is written, the original developer
> coded it as a static object:   CObjectClass m_MyObject.  So, as soon
> as the program starts, the infrastructure sees the declared object and
> fires the constructor for this object.  This constructor has other
> application objects in it that, you guessed it, are declared static.
> And on and on it goes.  So, when the parent object is declared, I get
> dozens of constructors firing before I execute one bit of code for the
> application itself.  If I have to, I'll redesign this to require
> NEW's, but for the moment, I don't have the time to consider this
> approach.
>
> Thanks for any pointers.... and prozac shipments :)


Relevant Pages

  • Re: Crashes in Debug (random) but not release
    ... >I am searching high and low for an invalid pointer (I agree it is something ... When looking at the constructor of the parameter ... >>>am linking in is corrupt or misaligned when generating a debug build. ...
    (microsoft.public.pocketpc.developer)
  • Re: Question about arrays in objects
    ... >>I want to create a 2d array as an object member. ... > handled in the constructor, you just can't use a plain old array. ... > that is where using a pointer would come in. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Strange EAccessViolation which I cannot figure out...
    ... where in your code you are freeing and setting it to NIL to then later ... The proper way is to always create it in the constructor or, ... type cast around this returned value as a pointer to a pchar string. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Dealing with HANDLEs
    ... On every new process event this program creates a new Process object and ... pointer and assigns the pointer from the to it. ... This worked in debug. ... Strange, I thought if I pass a pointer, it's like by ref, I can change its ...
    (microsoft.public.win32.programmer.kernel)
  • Re: C++ 101 dumb question
    ... Yep I do comprehend the difference between a pointer and the data it ... If you have a CMyClass a; ... What does the signature of a copy constructor look like? ... Its action is to copy the data members of the class, ...
    (microsoft.public.vc.language)