Re: Segfault with operator delete[]

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

 



Brian Hart wrote:
Hello:

I am using GCC v2.96 on Red Hat 7.3.

My C++ program ALWAYS seg faults when operator delete[] is called on a pointer, even though stepping through the code in the debugger reveals not
only the address to be valid, but also it is the same address as that returned by operator new.


This only happens when calling delete[] on arrays of primitive types besides char. An example of offending code is:

unsigned long* v = new unsigned long[100];

/* the above succeeds, let's say */
/*snip*/
...
/*snap*/

delete[] v;  /*<-- seg fault here; why?? */
v = NULL;

Does this have anything to do with the compiler? Oddly enough, if I
yes, IIRC there was a bug with deleting such arrays (to do with a 'cookie'
telling delete[] how big the array was). I beleive this is fixed in 3.3
(it certainly is in the current development tree.)

The pre 3.0 series compilers are no longer actively maintained.

nathan

--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
         The voices in my head said this was stupid too
nathan@xxxxxxxxxxxxxxxx    ::     http://www.planetfall.pwp.blueyonder.co.uk



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux