home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / mac / programm / 20797 < prev    next >
Encoding:
Internet Message Format  |  1993-01-06  |  1.8 KB

  1. 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
  2. From: biehl@ecn.purdue.edu (Larry Biehl)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: heap corruption problem
  5. Message-ID: <biehl-060193095743@msenmac2.ecn.purdue.edu>
  6. Date: 6 Jan 93 15:15:30 GMT
  7. Sender: news@noose.ecn.purdue.edu (USENET news)
  8. Followup-To: comp.sys.mac.programmer
  9. Organization: Purdue University
  10. Lines: 56
  11.  
  12. I am trying to determine the problem with a program that I have written
  13. which corrupts the heap when the block of memory represented by a handle
  14. is moved.  I have been able to replicate the problem with a small program
  15. given at the end of this message.  
  16.  
  17. I am using ThinkC 5.0.4 on a MacIIfx using system 7.0.1 with tuner 1.1.1
  18. and 32 bit memory address flag set.  The code is defined as 32bit
  19. compatible 
  20. and compiled using the 020 and 881 compiler flags.  
  21.  
  22. I have tested this program on an fx with 32 meg of memory and one with 
  23. 20 meg of memory.  The following program if given 17.5 meg of memory will
  24. crash during the last MoveHHi instruction.  If the last memory request
  25. of 9917920 is reduced to 9417920, the program will not crash.
  26.  
  27. Does anyone know what the problem is?
  28. Thanks.
  29.  
  30. void main ()
  31.  
  32. {
  33.             /* Declare local variables                                                            */
  34.     
  35.     Handle                    handle1;
  36.     Handle                    handle2;
  37.     
  38.     long int                    handleSize;
  39.     
  40.     unsigned long int        stackSize = 5000;        /* Add 5K more to the stack.        */
  41.  
  42.     
  43.     SetApplLimit ( (Ptr)( (unsigned long int)GetApplLimit() - stackSize ) );
  44.     
  45.     handleSize = 7208960;
  46.     handle1 = NewHandle(handleSize);
  47.     
  48.     handle2 = NewHandle(4112);
  49.     
  50.     if (handle1)
  51.         DisposeHandle (handle1);
  52.         
  53.     handleSize = 9917920;
  54.     handle1 = NewHandle(handleSize);
  55.     
  56.     if (handle1)
  57.         MoveHHi (handle1);
  58.     
  59.     MaxApplZone();
  60.     
  61.     if (handle1)
  62.         MoveHHi (handle1);
  63.     
  64.     ExitToShell ();
  65.         
  66.         
  67. }        /* end "main" */                                    
  68.