home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!wupost!zaphod.mps.ohio-state.edu!darwin.sura.net!jvnc.net!rutgers!news.cs.indiana.edu!noose.ecn.purdue.edu!msenmac2.ecn.purdue.edu!user
- From: biehl@ecn.purdue.edu (Larry Biehl)
- Newsgroups: comp.sys.mac.programmer
- Subject: heap corruption problem
- Message-ID: <biehl-060193095743@msenmac2.ecn.purdue.edu>
- Date: 6 Jan 93 15:15:30 GMT
- Sender: news@noose.ecn.purdue.edu (USENET news)
- Followup-To: comp.sys.mac.programmer
- Organization: Purdue University
- Lines: 56
-
- I am trying to determine the problem with a program that I have written
- which corrupts the heap when the block of memory represented by a handle
- is moved. I have been able to replicate the problem with a small program
- given at the end of this message.
-
- I am using ThinkC 5.0.4 on a MacIIfx using system 7.0.1 with tuner 1.1.1
- and 32 bit memory address flag set. The code is defined as 32bit
- compatible
- and compiled using the 020 and 881 compiler flags.
-
- I have tested this program on an fx with 32 meg of memory and one with
- 20 meg of memory. The following program if given 17.5 meg of memory will
- crash during the last MoveHHi instruction. If the last memory request
- of 9917920 is reduced to 9417920, the program will not crash.
-
- Does anyone know what the problem is?
- Thanks.
-
- void main ()
-
- {
- /* Declare local variables */
-
- Handle handle1;
- Handle handle2;
-
- long int handleSize;
-
- unsigned long int stackSize = 5000; /* Add 5K more to the stack. */
-
-
- SetApplLimit ( (Ptr)( (unsigned long int)GetApplLimit() - stackSize ) );
-
- handleSize = 7208960;
- handle1 = NewHandle(handleSize);
-
- handle2 = NewHandle(4112);
-
- if (handle1)
- DisposeHandle (handle1);
-
- handleSize = 9917920;
- handle1 = NewHandle(handleSize);
-
- if (handle1)
- MoveHHi (handle1);
-
- MaxApplZone();
-
- if (handle1)
- MoveHHi (handle1);
-
- ExitToShell ();
-
-
- } /* end "main" */
-