Fun_People Archive
4 Jan
I Broke Malloc

Date: Tue,  4 Jan 94 01:04:48 PST
To: Fun_People
Subject: I Broke Malloc

 From: (Pete Zakel)

I don't remember having seen this before, so hopefully I'm the first to
point out yet another meaning for the infamous TLA, IBM (see subject line).

It seems that in AIX version 3 (IBM's so-called Unix), the pointer returned
by malloc does not point to memory that has been allocated ...  (big pause)
...  yet (maybe it should be called malloc_not_really?).  The memory
supposedly allocated by malloc doesn't really get allocated until you
actually try to touch it, which is a big boon if you are using very large
very sparse arrays, but not very useful otherwise.

If, when you try to access the memory that you have supposedly allocated,
the allocator can't really give you the memory, the operating system kills
you off and outputs the cryptic and spectacularly unuseful message:

But wait!  All is not lost!

In their infinite wisdom, IBM has provided an interrupt that warns you that
you can't really access the memory that malloc_not_really said it gave you,
so that you can implement your own memory allocation scheme to do what
malloc normally does on any real Unix system (they even provide an example),
and the name of the signal is SIGDANGER.

I hereby decree (if I may be so bold) that this signal be henceforth and
forever known as SIGDANGER_WILL_ROBINSON -- for obvious reasons.

[=] © 1994 Peter Langston []