use Rc and Weak Presumably y'all are talking about doubly linked lists, singly linked lists are possible to do efficiently in safe code
-
-
Replying to @ManishEarth @andy_kelley and
There's also the possibility of using non-pointer references to represent the graph, such as indices into an array or some other pool data structure that holds the nodes
4 replies 0 retweets 8 likes -
Replying to @jckarter @ManishEarth and
This is the right answer in practice, if LinkedList<T> doesn’t work for you.
1 reply 0 retweets 2 likes -
I mean, for 99.9% of "practice" the right answer is "don't use a linked list", but for the remaining 0.1% ...
3 replies 0 retweets 3 likes -
Replying to @stephentyrone @pcwalton and
(More generally, for 99.9% of "data structures that you believe require unsafe" the right answer is "use indices instead of pointers, if you must.")
1 reply 0 retweets 4 likes -
Replying to @stephentyrone @pcwalton and
This is kinda true, but on the flip side it reinvents UAF.
1 reply 0 retweets 4 likes -
Replying to @RichFelker @stephentyrone and
The whole point (IMO; other aspects like bounds checking are relatively easier to solve) of advanced memory-safety in Rust is eliminating UAF - making it so there's no such thing as references to freed objects that can alias new unrelated objects.
1 reply 0 retweets 1 like -
Replying to @RichFelker @stephentyrone and
If you just use indices, now your indices are outside of that regime and can index a slot that's been freed and reused for something new. You just recreated C on top of Rust. Yay.
3 replies 0 retweets 2 likes -
Replying to @RichFelker @stephentyrone and
Of course it's somewhat "better" because you can only alias objects of the same type, and presumably they're part of the same larger data structure, but there's still plenty of room for attacker-controlled corruption leading to loss of control.
1 reply 0 retweets 0 likes -
Replying to @RichFelker @stephentyrone and
In practice this seems much rarer than UAF on an untyped heap, but yes.
1 reply 0 retweets 0 likes
(That is, an attacker hijacking control flow)
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.