Referencing through a null pointer
Henry Spencer
henry at utzoo.uucp
Sun Apr 24 19:27:40 AEST 1988
> Could someone please tell me which machine it was that started the
> unfortunate convention that referencing through the null pointer returns a
> zero with no error? I was under the impression it was BSD Unix, but I'm not
> sure.
Sigh, yet another example of Berkeley being given credit for something they
didn't do. In this case maybe we should let them have it, mind you... :-)
[pun intentional]
This convention started in split-space programs on the pdp11/45 under V6,
as an implementation accident: the data space really did begin at 0 in
a split-space program, so an anonymous variable was inserted there to make
sure that no normal variable had address 0, and unfortunately said variable
was initialized to 0. I'm not sure about V6, but there are V7 programs
that depend on this. So Bell Labs gets the blame here. (I hesitate to
blame Dennis in particular; he is probably responsible for the anonymous
variable, but it would have required unusual foresight to predict the
problems and put some strange value there instead of zero.)
Both System V and Berklix inherited the problem, but it *mostly* got cleaned
out of Berklix by early efforts at Sun that were fed back to Berkeley. It
keeps creeping back, since Berklix (unlike Sunnix) does not set up its page
map to trap accesses to location 0. Unless it's been fixed quite recently,
System V still has the problem, since AT&T likewise does not map out 0.
(If it comes to that, Sun would probably have preferred not to, but as I
recall it their early hardware gave them no choice.) Patches to make 4.2
map out zero have been posted in the past; the same could probably be done
for System V, but far more programs would break.
--
"Noalias must go. This is | Henry Spencer @ U of Toronto Zoology
non-negotiable." --DMR | {ihnp4,decvax,uunet!mnetor}!utzoo!henry
More information about the Comp.lang.c
mailing list