Hi. We are using your library at rust-analyzer, specifically rowan red-green syntax tree crate.
We have stumbled with invalid free() (here is the link to that issue).
I just took a quick look into the places where we use unsafe code and stepped into your crate. I am not entirely sure whether this comes from here, otherwise, I would've created a bug report.
I just have some questions about these lines of code here:
|
unsafe fn fatten_const(ptr: ErasedPtr) -> NonNull<Self> { |
|
let len = ptr::read(Self::len(ptr).as_ptr()); |
|
let slice = make_slice(ptr.cast::<SliceItem>().as_ptr(), len); |
|
NonNull::new_unchecked(slice as *const Self as *mut Self) |
|
} |
|
|
|
unsafe fn fatten_mut(ptr: ErasedPtr) -> NonNull<Self> { |
|
let len = ptr::read(Self::len(ptr).as_ptr()); |
|
let slice = make_slice_mut(ptr.cast::<SliceItem>().as_ptr(), len); |
|
NonNull::new_unchecked(slice as *mut Self) |
|
} |
First of alI, I am not a pro in unsafe counterpart of Rust, please just correct me if I am wrong.
My questions are:
- What is the intent of having two functions that have the same signature but operate on
*const _ and *mut _ pointers in their body respectively? I've heard this has something to do with pointer provenance, though I am not entirely sure in this context.
- It seems that we are casting ptr to
usize and to SliceItem at the first and the second lines of these functions (which is like we are doing type punning), but I don't see why we would do that. Could you please elaborate?
Hi. We are using your library at
rust-analyzer, specificallyrowanred-green syntax tree crate.We have stumbled with
invalid free()(here is the link to that issue).I just took a quick look into the places where we use
unsafecode and stepped into your crate. I am not entirely sure whether this comes from here, otherwise, I would've created a bug report.I just have some questions about these lines of code here:
thin-dst/src/lib.rs
Lines 111 to 121 in 1da8b7a
First of alI, I am not a pro in
unsafecounterpart of Rust, please just correct me if I am wrong.My questions are:
*const _and*mut _pointers in their body respectively? I've heard this has something to do with pointer provenance, though I am not entirely sure in this context.usizeand toSliceItemat the first and the second lines of these functions (which is like we are doing type punning), but I don't see why we would do that. Could you please elaborate?