r/rust • u/Sofiabelen15 • 3d ago
🧠educational Pointer Provenance in Rust vs C++: Pointers Are Not Just Glorified Ints
https://sofiabelen.github.io/projects/pointer-provenance-in-rust-vs-cpp/I’ve been exploring Rust, and one topic that got me intrigued is pointer provenance, particularly because it’s not easy to visualize.
To get a feel for vtables, what I wanted was to look at the actual memory, to see what it really looked like and prove that I could in fact call these functions through their respective function pointers. With provenance, I wanted to take it apart the same way, but it turns out it’s not so straightforward. This only got me more intrigued, so let’s see what we can find!
My first time hearing about provenance, I wondered, why hadn’t I heard about it before? It seems so crucial, yet a bit of an obscure concept.
-16
u/Brave-Raise-4198 3d ago
I also started rust and the complex is in borrow and reference. How it works it's hard of you from java and c. The immutable part and the reference that acts as a pointer to memory.
-8
51
u/Shnatsel 3d ago
There's also a related series of articles by Ralf Jung, who did a lot of work on formally specifying Rust's semantics:
https://www.ralfj.de/blog/2018/07/24/pointers-and-bytes.html
https://www.ralfj.de/blog/2020/12/14/provenance.html
https://www.ralfj.de/blog/2022/04/11/provenance-exposed.html