Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(swingset): track exported Remotables during export, not serializa…
…tion The `convertValToSlot` function is called during `m.serialize`, which happens in three places: * message send, just before `syscall.send()` * promise resolution into kernel, just before `syscall.resolve()` * when serializing virtualized data: * writing to the property of a virtual object * saving data to a value of a vref-keyed `makeWeakStore()` instance Remotables are assigned a vref during serialization. However we need to track two different kinds of reachability: * reachable by kernel: * this flag is set when syscall.send or syscall.resolve includes the Remotable's vref in the arguments * the flag is cleared when the kernel calls `dispatch.dropExport` * reachable by virtualized data: * this is flag is set when a virtual-object property setter or weakstore.init/set sees the vref in the serialized virtualized data * the flag is cleared when the virtualized data's last reference goes away We must retain a strong reference to the Remotable as long as either form of reachability is possible. The virtual object manager uses the `reachableRemotables` Set to retain this reference for everything in virtualized data. Liveslots uses the `exportedRemotables` Set to do the same for things that have been exported into the kernel. However, previously liveslots added things to `exportedRemotables` during *serialization*, which was wrong because the same serialization function is also used by virtualized data. So this patch changes liveslots to add the Remotable just *after* serialization in the two specific places that send things into the kernel: `syscall.send` and `syscall.resolve`. The failure mode this should fix would be: * vat creates a Remotable * vat stores Remotable into virtualized data * the old `convertValToSlot` would add Remotable to `exportedRemotables` * but nothing actually sent it into the kernel * VOM would also (correctly) add Remotable to `reachableRemotables` * vat drops strong reference to Remotable * leaving two strongrefs: `reachableRemotables` (correct), `exportedRemotables` (wrong) * virtualized data is deleted (e.g. `weakstore.delete()`, or state overwrite) * eventually (when we implement refcounting in the VOM), this will delete the strongref from `reachableRemotables` * then failure is that the Remotable is not released, because `exportedRemotables` still references it, and the kernel will never do `dispatch.dropExport` because the kernel never saw it I won't be able to test this until we implement more precise reachability tracking for virtualized data, which is going to be a while.
- Loading branch information