Download Cyclone

Transcript
Fat Pointers
Fat Pointers
A “fat” pointer; has run time
bounds: 3-word representation
Pointer arithmetic OK
H E L L O
q:
H E L L O
q++;
q[0]
q--;
q--;
q[0]
c f b
q:
q++;
q[0]
q--;
q--;
q[0]
c f b
Fat Pointers
Fat Pointers
Bounds check on dereference
H E L L O
q:
H E L L O
q++;
q[0]
q--;
q--;
q[0]
c f b
q:
q++;
q[0]
q--;
q--;
q[0]
c f b
Fat Pointers
Fat Pointers
Dangling pointers OK ...
… caught on dereference
H E L L O
q:
c f b
H E L L O
q++;
q[0]
q--;
q--;
q[0]
q:
c f b
q++;
q[0]
q--;
q--;
q[0]
5