effect of free()

andyj at eriador.prime.com andyj at eriador.prime.com
Sat Sep 9 06:21:00 AEST 1989


scott at bbxeng (Scott Amspoker) writes:
> In article <10973 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
> >In article <1010 at m3.mfci.UUCP> karzes at mfci.UUCP (Tom Karzes) writes:
> >>Nonsense.  There are no indirect or indexed references in the code above,
> >>hence no opportunities for invalid address traps.  Period.
> >
> >Loading an unmapped address descriptor into an address register may
> >cause an exception on some reasonable architectures.  Exclamation point.
>
>In other words - you cannot even *test* a pointer unless you are *sure*
>there is a valid address in it.  I don't think so.  Is NULL some kind
>of special exception?  Before we waste anymore bandwidth with this topic,
>does anybody actually know a specific architecture and C compiler combination
>that would cause a problem on a pointer compare?

Yes, the Prime 50-series architecture also must use special instructions to
load pointers.  The reasons are many:
  1.  The Prime is also a segmented architecture, and many segment addresses
      are not accessible to the user.
  2.  The Prime supports rings of protection.  While the ring bits are
      important in protecting access, they are not part of "the address" of
      the object, and must therefore be masked out.
  3.  The Prime allows for dynamic linking.  This is accomplished by creating
      a "faulted" pointer, which is resolved to the actual object at run-time
      (if it exists).  Thus, a pointer must be "resolved" to its destination
      before it can be used in any operation (assignment, comparision, or
      dereference).  Any comparison with the faulted pointer will yield an
      incorrect result.  Note that the compiler makes a special check for
      comparison or assignment with a null pointer constant, since a null 
      pointer would give an addressing failure if it went through the special
      instructions.

E. Andrew Johnson  (andyj at enx.prime.com)
Prime Computer, Inc.



More information about the Comp.lang.c mailing list