Use-after-free checking at low runtime cost
Use-after-free checking at low runtime cost
Posted May 4, 2022 1:12 UTC (Wed) by akkartik (guest, #158307)In reply to: DeVault: Announcing the Hare programming language by linuxrocks123
Parent article: DeVault: Announcing the Hare programming language
Since you seem interested in this space, I'll throw out one idea I particularly like and have used in a project [1]: manage heap allocations using a fat pointer that includes an allocation id. The pointer contains the allocation id and so does the payload. Every dereference of the fat pointer compares the allocation id in the pointer and payload. Freeing an allocation resets its allocation id. Future allocations that reuse the allocation will never generate the same allocation id. A use-after-free dereference then leads to an immediate abort, which is easier to debug and more secure.
The overhead of this scheme is too great for most C/Rust programmers, but I think it's much lower than tracking all pointers or indirections in structs containing pointers.
