Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!usc!snorkelwacker!bloom-beacon!eru!luth!sunic!nuug!hod!nic!arneme From: arneme@nic.uit.no (Arne Munch-Ellingsen) Newsgroups: comp.sys.mac.programmer Subject: ThinkC's handling of CODE resources. Keywords: ThinkC Message-ID: <1990Jul10.150057.24765@hod.uit.no> Date: 10 Jul 90 15:00:57 GMT Sender: news@hod.uit.no (USENET News System) Reply-To: arneme@sfd.uit.no Followup-To: arneme@nic.uit.no Organization: FORUT/University of Tromsoe, Norway. Lines: 29 I am working on a fairly large thinkC project that divides the code into 8 code segments. Trying to debug the project I single steps the program using the "step" and "in" commands up to the following statement: button_name = (char *)malloc( maximum_name_length + 1 ); Using the Data window gives this value for maximum_name_length: maximum_name_length = 27 The call to malloc never returns, the mac hangs on me. This makes me wonder about how thinkC handles it's CODE segments. It seems to me that the CODE segment from where malloc is called is relocated while the malloc is executing. On return from malloc the return address is taken from the stack, and oops, the CODE segment is not there anymore. I had another problem of this sort, running code in CODE segment 1, calling a routine in another segment resulted in a jump to an address where the code for the called routine was not located. Moving the file in question to CODE segment 1 resulted in that the routine was found and executed without problems. I am not doing any UnloadSeg or GetResource calls in my program source. Has anyone experienced similar behavior when using thinkC, or is it probable that my guess on what is happening is far out? Arne.