"Ivan Vecerina" <INVALID_use_webform_instead@vecerina.com> wrote in message news:cunf2u$j3a$1@news.hispeed.ch...[color=blue]
> "Alex Vinokur" <alexvn@big-foot.com> wrote in message
> news:378dcgF59bc1uU1@individual.net...[color=green]
> > GNU g++ 3.3.3, Cygwin[/color]
> ...[color=green]
> > mbuffer = new (nothrow) char [1001];
> > assert (mbuffer != NULL);
> >
> > // Stuff[/color]
> Methinks this Stuff is what actually causes the crash.
>[color=green]
> > assert (mbuffer != NULL);
> > delete[] mbuffer; // Sometimes crashed here (not always).[/color]
>
> Except if you somehow change the value of mbuffer,
> some buffer overflow is most likely corrupting the heap
> and causing the crash.
>
> Most platforms have tools that can help you detect heap
> corruption, or a debugging implementation of heap allocation
> functions.
> A poor man's first try could also be to do:
> mbuffer = 1+new (nothrow) char [1001+2];
> mbuffer[-1] = 0x77; //magic number to detect overwrite
> mbuffer[1001] = 0x77;
>
> //Stuff... <-- look for change of mbuffer[-1 or 1001]
> // e.g. by inserting assertions..
>
> delete[] (mbuffer-1);
>
>
>
> --
>
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
>
>[/color]
Ivan,
I started to apply your method and while analyzing the code I found out the cause of the problem.
Of course, it was trampling memory.
infile.read (mbuffer, infile_size); // infile_size was greater than mbuffer size.
Thank you very much.
--
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html http://sourceforge.net/users/alexvn