Bounds-check Array access for the debug runtime#2675
Conversation
| @@ -226,11 +226,13 @@ impl Array { | |||
| } | |||
|
|
|||
| pub unsafe fn get(self: *mut Self, idx: u32) -> SkewedPtr { | |||
There was a problem hiding this comment.
@osa1 I wonder if *const Self would be appropriate here...
There was a problem hiding this comment.
@ggreif these methods currently all have *mut Self receiver because until recently it wasn't possible to call a *const Self method on a *mut value, see rust-lang/rust#80258. Without the fix for that issue it's quite noisy to use these methods as we need casts x as *const _ everywhere.
I fixed that issue in rust-lang/rust#82436 so we just need to update rustc.
There was a problem hiding this comment.
Not many people seem to use raw pointers in Rust... 🤔
There was a problem hiding this comment.
MMTk is also implemented in Rust, I'd expect it to use raw pointers in the GC code. Would be interesting to look at how they use raw pointers.
There was a problem hiding this comment.
Maybe we can prune this list then?
// TODO (osa): Some of these are stabilized, we need to update rustc
#![feature(
arbitrary_self_types,
panic_info_message,
assoc_char_funcs,
core_intrinsics,
ptr_offset_from
)]There was a problem hiding this comment.
Yeah most of those should also be gone with an update.
|
This PR does not affect the produced WebAssembly code. |
Array access for the debug runtime
This adds debug assertions that no access outside of
Array's length is attempted.