(To head off objections: you technically have memory safety even if you have leaks, so you don't technically need smart pointers. But I'll consider smart pointers part of the safety story for the sake of argument.)
-
-
Show this threadThanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Smart pointers for refcounted classes prevent UAFs by automatically calling AddRef.
-
True. Though it’s easy to subvert by just using shared_ptr<Foo>& rather than shared_ptr<Foo>.
- 3 more replies
New conversation -
-
-
isn't Rust quite literally built on the fact that leaks are safe?
-
leaks are allowed to be caused in safe code, doesn't mean it's /easy/ to leak
- 4 more replies
New conversation -
-
-
Interesting that the defence against UAF is static, but the defence against leaks is dynamic. I guess this is inevitable in Rust, you'd need gc for dynamic protection against UAF, or linear types for static protection against leaks.
-
Yep, GC is an alternative that addresses both issues.
- 2 more replies
New conversation -
-
-
Memory leaks don't lead to UB, do they? How exactly is leaking memory unsafe?
- 1 more reply
New conversation -
-
-
This Tweet is unavailable.
-
Rust doesn’t prevent (all) memory leaks. It is explicitly stated in the documentation that memory leaks are deemed safe. You can for example have memory leaks via cyclic refcounted data.
End of conversation
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.