>One approach to this was taken by IBM, where there is a machine
>instruction called TPROT (Test Pro tection).  This instruction can be
>handed a suspicious address and an accessing process.  TPROT the n sets
>a flag as to whether or not that reference by that process would core
>if attenpted.  TPROT c an be used by the kernel to check itself as
>well.


Solaris has the mincore() system call which will reveal the truth about
valid addresses but is, of course, hideously expensive as it is a system
call.

On SPARC v9 we have non-faulting loads (ASI_PRIMARY_NOFAULT) which can
serve some of this purpose.

But see my other reply as to why derefencing the pointer by printf
is completely valud.

Libraries should be very strict in what they accept; and they should
fail for anything else because any sloppiness accepted in code
will come back to haunt you eventually.

E.g., if a specific function is called with a structure argument which
has a few "reserved, must be zero" fields and the function works when those
fields are non-zero, then a future version of the OS which does give meaning
to such fields will cause the application to break.

By being strict you find bugs early and not when a new version of the
OS comes out after the apoplication has shipped; you find it when developing
the application.  And that is the best time to find such bugs.

Casper
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to