wiggle: Refactor with fewer raw pointers#5268
Conversation
This commit refactors the internals of `wiggle` to have fewer raw pointers and more liberally use `&[UnsafeCell<_>]`. The purpose of this refactoring is to more strictly thread through lifetime information throughout the crate to avoid getting it wrong. Additionally storing `UnsafeCell<T>` at rest pushes the unsafety of access to the leaves of modifications where Rust safety guarantees are upheld. Finally this provides what I believe is a safer internal representation of `WasmtimeGuestMemory` since it technically holds onto `&mut [u8]` un-soundly as other `&mut T` pointers are handed out.
Subscribe to Label Actioncc @kubkon DetailsThis issue or pull request has been labeled: "wasi"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
abrown
left a comment
There was a problem hiding this comment.
Makes sense to me. I think there are some additional changes here beyond the &[UnsafeCell<T>] one that might be worth documenting; e.g., it isn't clear to me exactly why we are removing validate here and in the future it might be good to remember the "why". Perhaps some reasoning in the squashed commit message would help?
|
Ah yes indeed sorry about that. The |
This commit refactors the internals of
wiggleto have fewer raw pointers and more liberally use&[UnsafeCell<_>]. The purpose of this refactoring is to more strictly thread through lifetime information throughout the crate to avoid getting it wrong. Additionally storingUnsafeCell<T>at rest pushes the unsafety of access to the leaves of modifications where Rust safety guarantees are upheld. Finally this provides what I believe is a safer internal representation ofWasmtimeGuestMemorysince it technically holds onto&mut [u8]un-soundly as other&mut Tpointers are handed out.Additionally generated
GuestTypeTransparentimpls in thewigglemacro were removed because they are not safe for shared memories as-is and otherwise aren't needed for WASI today. The trait has been updated to indicate that all bit patterns must be valid in addition to having the same representation on the host as in the guest to accomodate this.