[TUHS] history of virtual address space
Alan Coopersmith via TUHS
tuhs at tuhs.org
Tue Jan 20 10:48:27 AEST 2026
On 1/19/26 15:10, Luther Johnson via TUHS wrote:
> I once found an old version of RCS that expected *0 = 0, and I think many other
> programs did as well. I'm not sure which versions of Unix did or still do this
> any more, but I believe many had the first page in virtual address space for
> user program processes, mapped to a read-only page of zeroes, to support this.
> If I'm remembering that wrong, I'm interested as the other posters here are, in
> the details of which did which sorts of things.
Deep in the SunOS SCCS archives, the initial checkin of the string(3) man page,
labeled as:
D 1.1 83/08/30 15:57:14 wnj 1 0 00103/00000/00000
date and time created 83/08/30 15:57:14 by wnj
contains this warning in the "BUGS" section:
On the Sun processor (and on some other machines), you can NOT use a
zero pointer to indicate a null string. A zero pointer is an error and
results in an abort of the program. If you wish to indicate a null
string, you must have a pointer that points to an explicit null string.
On PDP-11's and VAX'en, a source pointer of zero (0) can generally be
used to indicate a null string. Programmers using NULL to represent an
empty string should be aware of this portability issue.
This warning was apparently not sufficient, since in 1994, Bill Shannon added
the "0 at 0.so.1" object to Solaris, which you could use with LD_PRELOAD to mmap
a page from /dev/zero to the page at address 0, as described in the ld.so.1(1)
man page:
The user compatibility library /usr/lib/0 at 0.so.1 provides a mechanism
that establishes a value of 0 at location 0. Some applications exist
that erroneously assume a null character pointer should be treated the
same as a pointer to a null string. A segmentation violation occurs in
these applications when a null character pointer is accessed. If this
library is added to such an application at runtime using LD_PRELOAD,
the library provides an environment that is sympathetic to this errant
behavior. However, the user compatibility library is intended neither
to enable the generation of such applications, nor to endorse this par-
ticular programming practice.
In many cases, the presence of /usr/lib/0 at 0.so.1 is benign, and it can
be preloaded into programs that do not require it. However, there are
exceptions. Some applications, such as the JVM (Java Virtual Machine),
require that a segmentation violation be generated from a null pointer
access. Applications such as the JVM should not preload
/usr/lib/0 at 0.so.
There are more lines of comments than code in the source for it:
https://github.com/illumos/illumos-gate/blob/master/usr/src/cmd/sgs/0%400/common/0%400.c
--
-Alan Coopersmith- alan.coopersmith at oracle.com
Oracle Solaris Engineering - https://blogs.oracle.com/solaris
More information about the TUHS
mailing list