-
Notifications
You must be signed in to change notification settings - Fork 129
Open
Description
While working on #520 other soundness and safety issues came up, this is something of an omnibus issue regarding them.
By "handle like types" I mean RootedGuard, RootedVec, MutableHandle, and JS::MutableHandle, as well as potentially RootedTraceableBox, and CustomAutoRooter.
Soundness - correct use of the public API results in undefined behavior
-
Traceablemodifies values behind a&Treference (Traceable is unsound #560). -
RootedGuardstores a&mutreference to data the GC looks at and modifies over GC pauses (RootedGuard<T> construction related unsoundness #564). -
MutableHandleis constructed via a&mutreference, which will be invalidated by GC (Remove DerefMut impl for RootedGuard #572). -
Handlestores an&reference to data (not wrapped in aCelltype) that the GC modifies over GC pauses. - The
Derefimplementations for handle like types allow for safe code to hold an&reference to data (not wrapped in aCelltype) that the GC will modify at over GC pauses. (Arguably a safety issue not a soundness issue, but I think we'll end up allowing borrowing over GC pauses).- Some of this data is modified via
Traceable. - Some of this data is modified directly in
RootedviaRootKind.
- Some of this data is modified via
- (TODO: Verify)
ForOfIteratorGuard::newis suspicious, it likely has issues similar to those described in RootedGuard<T> construction related unsoundness #564.
Safety - it's possible to use this improperly in safe code
- The
DerefMutimplementations for handle like types allow for safe code to hold an&mutreference to data the GC will look at and modify over GC pauses. - MutableHandle are clonable breaking safety provided by &mut #520
- Remove Copy/Clone from MutableHandle #559
- Remove DerefMut impl for
JS::MutableHandle#574 -
JS::MutableHandleallows mutating an&Treturned fromDerefviaseton an aliasing handle.
-
JS::[Mutable]Handleallows use after free in safe code via-
DerefMutRemove DerefMut impl forJS::MutableHandle#574 -
Deref,get, andset
-
Assumptions in comments on public APIs
- The comment added in Remove DerefMut impl for RootedGuard #572 on the
as_ptrmethod assumes that the GC will only read - i.e. writes will occur through interior mutability. If that ends up not being the case, the comment should be updated.
sagudev and wusyong
Metadata
Metadata
Assignees
Labels
No labels