Skip to content

Prevent unsafe use of RootedVec containing GC values #40141

@jdm

Description

@jdm

As determined in #39766, RootedVec<JSVal> is not a safe construct; GC values that live in heap memory need to stored in Heap wrappers, which enforces the correct barriers. However, it also isn't safe to use RootedVec<Heap<JSVal>> in case the underlying vector moves in memory during resizing.

This is a problem for code that is using a RootedVec to safely create a HandleValueArray; I think we need an alternative RootedArray which is a fixed size with inline memory and can be used with the rooted! macro. We should then remove the ability to create a HandleValueArray from a RootedVec and lint against RootedVec<JSVal>.

Existing uses that I've found:

Metadata

Metadata

Assignees

Labels

A-content/bindingsThe DOM bindingsA-crownServo's linterI-safetySome piece of code violates memory safety guarantees.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions