Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!unido!laura!anton!bause From: bause@anton.informatik.uni-dortmund.de ( ??? Bause ???) Newsgroups: comp.lang.c++ Subject: Zortech: heap corrupted (Summary of answers) Message-ID: <2358@laura.UUCP> Date: 3 Aug 90 10:36:39 GMT Sender: news@laura.UUCP Reply-To: bause@unido.uucp (Falko Bause) Organization: y Lines: 114 Thanks to all, who have answered me. A list of answers is following: Falko ============================================================================ From jbuck@ohm.berkeley.edu Wed Aug 1 21:16:09 1990 To: bause@unido.uucp (Falko Bause) Subject: Re: Zortech Problem: heap corrupted In article <2353@laura.UUCP> you write: |> A friend of mine is using Zortech 2.0. He uses hashed search tables and |> binary tree search tables. After some insertions into both tables he gets |> the error message: heap corrupted. |> |> Is this is known error of Zortech's C++? No. Zortech C++ is detecting an error in your friend's program. The heap is corrupted if you try to delete the same memory twice, or if you write on memory that has already been deleted. Have him check all use of new and delete, and also look at how his destructors are written. The term "heap" refers to the hunk of memory managed by the new and delete operators (or, in C, malloc and free). -- Joe Buck jbuck@galileo.berkeley.edu {uunet,ucbvax}!galileo.berkeley.edu!jbuck ============================================================================ From bright@dataio.uucp Thu Aug 2 16:06:52 1990 To: bause@unido.uucp Newsgroups: comp.lang.c++ Subject: Re: Zortech Problem: heap corrupted Summary: Expires: References: <2353@laura.UUCP> Sender: Followup-To: Distribution: Organization: Data I/O Corporation; Redmond, WA Keywords: In article <2353@laura.UUCP> bause@unido.uucp (Falko Bause) writes: 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 Posted: Fri Aug 3 07:05:16 1990 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 >