Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(SwingSet): VOM retains Remotables used in virtualized data #3153

Merged
merged 1 commit into from
May 21, 2021

Conversation

warner
Copy link
Member

@warner warner commented May 21, 2021

Userspace might store a locally-created Remotable (e.g. Far('iface', {methods..}) in the state of a virtual object, or somewhere in the value
of a vref-keyed makeWeakStore() entry. In either case, the data is
virtualized: serialized and written to disk. This serialized form obviously
cannot keep the Remotable JS Object alive directly, however userspace
reasonably expects to get the Remotable back if it reads the state or does
a .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

@warner warner added the SwingSet package: SwingSet label May 21, 2021
@warner warner added this to the Testnet: Stress Test Phase milestone May 21, 2021
@warner warner requested a review from FUDCo May 21, 2021 22:02
@warner warner self-assigned this May 21, 2021
Base automatically changed from refactor-vom to master May 21, 2021 22:10
Copy link
Contributor

@FUDCo FUDCo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OIC

Userspace might store a locally-created Remotable (e.g. `Far('iface',
{methods..})` in the `state` of a virtual object, or somewhere in the value
of a vref-keyed `makeWeakStore()` entry. In either case, the data is
virtualized: serialized and written to disk. This serialized form obviously
cannot keep the Remotable JS `Object` alive directly, however userspace
reasonably expects to get the Remotable back if it reads the `state` or does
a `.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
@warner warner force-pushed the 3132-vom-retain-remotables branch from 6c4aadc to ebbb520 Compare May 21, 2021 23:27
@warner warner enabled auto-merge (rebase) May 21, 2021 23:27
@warner warner merged commit e4ed4c0 into master May 21, 2021
@warner warner deleted the 3132-vom-retain-remotables branch May 21, 2021 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SwingSet package: SwingSet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

virtual object manager must retain strongref to Remotables in virtualized data
2 participants