nuta / kerla

A new operating system kernel with Linux binary compatibility written in Rust.
Other
3.33k stars 89 forks source link

Add lifetime to `PAddr` and `VAddr` #142

Open nuta opened 2 years ago

nuta commented 2 years ago

In #141, I noticed that we need to track the lifetime of a PAddr object which references to OwnedPages. It's problematic because it lead to memory leaks or nasty use-after-free bugs. In this issue, I'll replace PAddr and VAddr as:

#[repr(transparent)]
pub struct PAddr<'a> {
    value: usize,
    _pd: PhantomData<&'a ()>,
}