r/ProgrammingLanguages • u/matklad • Aug 06 '26
Memory Safety's Hardest Problem
https://matklad.github.io/2026/07/20/memory-safety-hardest-problem.html
32
Upvotes
r/ProgrammingLanguages • u/matklad • Aug 06 '26
8
u/thehenkan Aug 06 '26
Type confusion is absolutely a security issue, it just happens to be harder to induce than out of bounds accesses.
22
u/matthieum Aug 06 '26
Click-bait? Maybe... maybe not.
A lot of memory-safety issues can at least be solved at run-time (bounds-checking) but even with a tagged union, as long as you can capture a pointer to a member prior to overwriting everything, you're screwed.
Rust solves this with the BIG HAMMER (Aliasing XOR Mutability, aka borrow-checker), at the cost of ergonomics.
It can also be "solved" by indirection (ie, every member of a union is independently allocated) at the cost of performance. Meh.
3
u/alphaglosined Aug 06 '26
Nice, a random mention of u/WalterBright
4
u/L8_4_Dinner (Ⓧ Ecstasy/XVM) Aug 07 '26
Maybe just don't use memory unsafe languages?
1
u/reini_urban Aug 07 '26
That's trivial. The biggest isuue is not to let any user handle memory by himself, use a GC (and certainly not recounting). Ownership tracking also helps with performance and concurrency. Bounds checking is needed only for the bad languages