4 ms·
Isn't stack/arena allocation still vulnerable to dangling pointers?
by andreareina 4y ago
Isn't stack/arena allocation still vulnerable to dangling pointers?
- vitiral 4y agoOf course, it's still manual memory and pointer management after all. You could manually assign a pointer to 0xDEADBEEF if you want, or you could tell the arena to pop data that you are still using. The point is not perfection, it is simplicity and mapping tools to requirements.
- andreareina 4y agoMaybe I'm not understanding the point of the article then. It starts out as a polemical rant against the suggestion to use safer languages, and I guess I expected it to culminate in something more profound wrt safety. I use managed memory languages so I'm sure there's stuff I'm missing.
- williamcotton 4y agoThe point of the article is that there are useful heap memory management techniques that live between the extremes of malloc and free pairs and garbage collection. All of my formal instruction in C never mentioned this middle ground and it took both trial and error and working experience to learn about memory arenas. Also, I’m convinced that evangelizing Rust memory safety has probably done more harm than good because to outsiders it is being made to seem like anything done in C is wrong and stupid and therefore no one should pay any attention to anything that has ever been written in C. One of my worries before I start working in Rust is that I won’t be able to use my knowledge of resource management in C. That’s not the case at all but it takes having to filter through flame wars to figure things out!
- rfleury 4y agoYes, although there are debugging techniques you can use to mitigate the issue. For instance, in debug builds, upon popping off an arena, zero all popped pages, and mark them as no-access.