fix(SwingSet): VOM retains Remotables used in virtualized data #3153
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Userspace might store a locally-created Remotable (e.g.
Far('iface', {methods..})
in thestate
of a virtual object, or somewhere in the valueof a vref-keyed
makeWeakStore()
entry. In either case, the data isvirtualized: serialized and written to disk. This serialized form obviously
cannot keep the Remotable JS
Object
alive directly, however userspacereasonably expects to get the Remotable back if it reads the
state
or doesa
.get
on the store.To ensure the Remotable can be looked up from the serialized vref, the
virtual object manager must retain a strong reference to the original
Remotable for as long as its vref is present anywhere in the virtualized
data.
For now, we simply add the Remotable to a strong Set the first time it is
added, and we never remove it. This is safe, but conservative.
To do better (and eventually release the Remotable), we'll need to add some
form of refcount to each vref. When the refcount of the Remotable's vref
drops to zero, the VOM can drop its strong reference to the Remotable.
closes #3132
refs #3106