Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!tut!funic!santra!hutcs.hut.fi!jaa From: jaa@hutcs.hut.fi (Jari Alasuvanto) Newsgroups: comp.lang.c++ Subject: Re: Zortech Problem: heap corrupted Message-ID: <1990Aug3.060516.7577@santra.uucp> Date: 3 Aug 90 06:05:16 GMT References: <2353@laura.UUCP> <2605@dataio.Data-IO.COM> Sender: news@santra.uucp (Cnews - USENET news system) Organization: Helsinki University of Technology, Finland Lines: 31 In article <2605@dataio.Data-IO.COM> bright@Data-IO.COM (Walter Bright) writes: > >The "heap is corrupted" message is generated by the free() function under >the following conditions: >A common source of this error in C++ programs is when the compiler generates >a default copy constructor, and the objects contain pointers to malloc'd >data. (It's not a compiler bug!) I would add one common one to the list: a bug in your code using strings (applies to C as well): void causeError( const char* aString) { char* tmp = new char[ strlen(aString) ] ; // OOPS, forgot to add one for // terminating null strcpy ( tmp, aString ) ; } Errors of this kind will most likely go unnoticed for Motorola based machines and SPARCs, but with Intel-based architecture, the heap gets corrupted. This is due to different byte ordering. Check your code first before the compiler. -- Jari Alasuvanto, Lab. of Info Proc. Sci, Helsinki Univ. of Techology, Finland Internet: jaa@hutcs.hut.fi tel: +358-0-451 3236 fax: +358-0-465 077 >