NULL pointer problem on SUN

Dave Jones djones at megatest.UUCP
Fri Nov 16 09:19:43 AEST 1990


>From article <1255 at digi.lonestar.org>, by theruska at digi.lonestar.org (Thomas Heruska):

> For some reason, it crashes at this point ONLY on the Sun.  Has anyone 
> encountered this problem before?  It is obviously not a problem with
> strtok, but rather with copying a NULL pointer to a string.

"Obviously", the problem is in the program itself, not the Sun software.

There is no such thing as "copying a NULL pointer to a string."
Get yourself a copy of _The C Programming Language_ by Kerninghan and
Ritchie, and read the chapter on "Pointers and Arrays".

The reason your program worked on the other computer was no doubt
due to coincidences: On that machine, the NULL pointer happens to be
a valid machine address; the hardware does not trap program acesss to
that address as an bus-error; and at that address there just happens to
be a zero-byte. Because there is so much software in existence that works
only because of that coincidence, and because the NULL pointer is often
assumed to be address zero, most vendors whose machine-architecture's
will allow it put a zero in byte zero. But on some machines, you just
can't do that. Address zero often has a special purpose, so you are
constrained on what can be stored there. On many machines, address zero is
not even part of an application program's address-space.



More information about the Comp.lang.c mailing list