Referencing NULL pointers

Root Boy Jim rbj at dsys.ncsl.nist.gov
Fri Jul 14 06:56:27 AEST 1989


? From: Guy Harris <guy at auspex.auspex.com>

? For reasons cited in my posting, even if it *doesn't* cause a
? segmentation violation, the behavior isn't guaranteed; on such systems,
? you'd be most likely to get whatever stuff was lying around location 0
? in your address space, and that can be almost anything. 

Which, under the right circumstances, might be what you want. Consider
the following structure on a 680x0:

	struct vec {
		long boot_sp;
		long boot_pc;
		long bus_trap;
		...
	} *p0 = 0;

	p0->bus_trap = (long) <some_routine>;

When probing for memory at boot time, the kernel temporarily substitutes
its own trapping routine. Admittedly, this is an uncommon use of this
technique, and it probably doesn't use a structure anyway, but it could.

? "valid" doesn't mean "anything you can get away with without a core
? dump".

This statement is absolutely correct. The case I mentioned is the only
legal use of the zero pointer. And its definitely non-portable, as no
two machines seem to have the same page zero format.

	Root Boy Jim
	Have GNU, Will Travel.



More information about the Comp.unix.wizards mailing list