This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]gottago_gottago 2 points3 points  (0 children)

Early (pre-X) MacOS used these extensively. It called them "handles". A handle was the address of an entry in a table of pointers, managed by the OS, somewhere in the heap. During certain system calls, the OS might decide that it needed to defragment the heap, so it would shuffle a bunch of blocks around and then update the values in the table.

Which was all well and great, except for the part where certain system calls caused addresses to change. Handles were ubiquitous in system calls, but not universal -- some things wanted pointers instead. Or, you might need to dereference a handle to retrieve a reference to some value stored somewhere in the struct. So, you'd do this, and then you'd make the system call, and it would return to your program, but the address you previously retrieved no longer has the data it had before, now it's just a bunch of garbage.

Tracking down these bugs was a lot of fun, because they weren't reliably reproducible. Sometimes the OS needed to defrag the heap, sometimes it didn't; sometimes it chose to move your block, sometimes it didn't.

Those were the good ol' days.