help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: delete causes crash with a character array


From: Alex Vinokur
Subject: Re: delete causes crash with a character array
Date: Sun, 13 Feb 2005 14:48:47 +0200

"Ulrich Eckhardt" <doomster@knuut.de> wrote in message 
378uu2F590sktU1@individual.net">news:378uu2F590sktU1@individual.net...
> Alex Vinokur wrote:
> > GNU g++ 3.3.3, Cygwin
> [...]
> > static char* mbuffer = NULL;
> > void doit()
> > {
> >   // Stuff
> >   mbuffer = new (nothrow) char [1001];
> >   assert (mbuffer != NULL);
> >
> >   // Stuff
> >
> >   assert (mbuffer != NULL);
> >   delete[] mbuffer;   // Sometimes crashed here (not always).
> >   mbuffer = NULL;
> >
> >   // Stuff
> > }
> >
> > How can one detect what causes the crash?
>
> The code you show is fine, though you should check for the returnvalue of
> new (hint: assert() is not enough). Please reduce that to a minimal
> example that reproduces the described behaviour and make a backtrace while
> running in a debugger. Also, is this specific to g++ and/or Cygwin? I
> guess the problem is in the code you don't show, something like smashing
> the stack/heap or so.
>
[snip]

Thank you very much.
The problem solved.
It was trampling memory:
http://groups-beta.google.com/group/comp.lang.c++/browse_frm/thread/834019800cd74156/0d76d79a23464bca


-- 
 Alex Vinokur
     email: alex DOT vinokur AT gmail DOT com
     http://mathforum.org/library/view/10978.html
     http://sourceforge.net/users/alexvn





reply via email to

[Prev in Thread] Current Thread [Next in Thread]