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
-
Traceable
modifies values behind a&T
reference (Traceable is unsound #560). -
RootedGuard
stores a&mut
reference to data the GC looks at and modifies over GC pauses (RootedGuard<T> construction related unsoundness #564). -
MutableHandle
is constructed via a&mut
reference, which will be invalidated by GC (Remove DerefMut impl for RootedGuard #572). -
Handle
stores an&
reference to data (not wrapped in aCell
type) that the GC modifies over GC pauses. - The
Deref
implementations for handle like types allow for safe code to hold an&
reference to data (not wrapped in aCell
type) 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
Rooted
viaRootKind
.
- Some of this data is modified via
- (TODO: Verify)
ForOfIteratorGuard::new
is 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
DerefMut
implementations for handle like types allow for safe code to hold an&mut
reference 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::MutableHandle
allows mutating an&T
returned fromDeref
viaset
on an aliasing handle.
-
JS::[Mutable]Handle
allows use after free in safe code via-
DerefMut
Remove 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_ptr
method 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.
Metadata
Metadata
Assignees
Labels
No labels