🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.programmer
3 messages
3 total messages Started by Bob Beauchemin Thu, 21 Jan 1993 01:28
Memory Allocation Error
#2210
Author: Bob Beauchemin
Date: Thu, 21 Jan 1993 01:28
16 lines
864 bytes
  I'm having a problem with the NeXT 2.1 compiler and wonder if anyone else
has experienced it. Code that compiles OK and works on other platforms
fails on the NeXT. The error messages (at program execution) are:

  memory allocation error: attempt to free or realloc space not in heap
  bad zone
  IOT trap

  Has anyone else experienced this problem and/or have a solution or
explanation? Its happened on three different separate programs.

  Thanks (in advance),

Bob Beauchemin
bobb@agora.rain.com
Re: Memory Allocation Error
#2213
Author: Erich S. Boleyn
Date: Thu, 21 Jan 1993 12:08
34 lines
1786 bytes
bobb@agora.rain.com (Bob Beauchemin) writes:


>  I'm having a problem with the NeXT 2.1 compiler and wonder if anyone else
>has experienced it. Code that compiles OK and works on other platforms
>fails on the NeXT. The error messages (at program execution) are:

>  memory allocation error: attempt to free or realloc space not in heap
>  bad zone
>  IOT trap


   I have seen this problem many times.  It has always (so far at least)
been caused by attempting to call 'free' on a statically allocated string.

   Interestingly enough, running this on SunOS seems to work just fine,
i.e. it ignores such requests and goes on without an eyeblink.

   I've had to fix GNU readline, some berkeley daemons, helped a friend
with the really cool FTP daemon from wuarchive, etc.  and this is in
many cases pretty much the only problem.  Hint:  always look for it! ;-)

   Basically, your answer is to just bite the bullet and fix the bad
code that technically shouldn't have worked anyway, even though SunOS
and a few others are permissive.

   Good luck,
      Erich Boleyn

--
             "I haven't lost my mind; I know exactly where it is."
   / --  Erich Stefan Boleyn  -- \        --=> *Mad Genius wanna-be* <=--
  { Honorary Grad. Student (Math) }-->  Internet E-mail: <erich@cs.pdx.edu>
   \  Portland State University  /       WARNING: INTERESTED AND EXCITABLE
Re: Memory Allocation Error
#2222
Author: Jos Vermaseren
Date: Thu, 21 Jan 1993 15:37
30 lines
2081 bytes
In article <C16K2t.HGC@agora.rain.com>, bobb@agora.rain.com (Bob Beauchemin) writes:
> 
>   I'm having a problem with the NeXT 2.1 compiler and wonder if anyone else
> has experienced it. Code that compiles OK and works on other platforms
> fails on the NeXT. The error messages (at program execution) are:
>
The argument that it runs on other platforms is not so good. Many old style
UNIX programmers messed up int's and pointers freely.....
 
I have had similar problems with free when you give it a pointer that
you did not get from malloc before (like a NULL pointer). It can result
in very erratic behaviour after the (illegal) freeing.
It is just one of those things....
  The standard says what free should do when everything is swell but
of course the question is what it should do when things are wrong. Standards
rarely specify. You could crash the program, continue execution which a
poisoned system (what NeXT does) or when you manage to set up malloc and
free in such a way that nothing gets poisoned just keep running
(like many other systems do).
Unless there is a real programming error inside Mach, I guess formally you
cannot blame NeXT too much. You should have a good look inside your program
and make sure that each pointer that is freed is allowed to be freed.
A little macro like
#define MyFree(x)  if ( x != NULL ) { free(x); x = NULL; }
can work miracles. You could sneak in an else with an error message if you
want to see whether you try to free the same thing twice.
Of course it would be nice if the NeXT would crash the program rather than
continue running.....  Or would it? Maybe a good error message?

Jos Vermaseren
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads