-
Notifications
You must be signed in to change notification settings - Fork 215
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
can virtual objects or the WeakStore hold a Promise? #2485
Comments
I think @erights 's recent "virtual collections" work is heading towards a design where anything serializable can be used as data in the collection, and anything both serializable and having a stable identity can be used as a key or index. The latter requirement rules out the use of Promises there. I floated the idea that maybe we could exclude Promises from being keys of the
Ok, when I write it up that way, userspace is sensing the resolution of the promise, not the collection of the Promise object, which is ok. I'll have to think about it further. @erights said that forbidding Promises from being used as keys of (what look like) plain WeakMaps would be pretty drastic, so we'd prefer to not do that if at all possible. |
@FUDCo I know you and @erights have a whole scheme for what objects can be used in what contexts. You're closer to those docs than I am, so I'm assigning this to you two with the specific question of "can Promises be held in virtual or durable data?" (so virtual objects Once you've got an answer, assign it back to me. If the answer is "no", I'll probably close this with some commentary. If the answer is "yes", then we've got a bigger problem to address. I'll set the ticket size to "1" because I'm guessing (hoping?) the answer will be "no". |
With respect to durable data, the answer is a definite "no", at least with respect to Promises per se, since promises don't survive the death and resurrection of a vat. Obviously if you hold a presence to a remote object that was imported, you can't actually tell if it's a promise on the remote end or not, but at that point you don't care because the remote vat's promise GC behavior is not your concern. With respect to virtual data, it appears we do allow promises to be used as values in virtual objects and stores, but not as keys in stores. It's also not obvious to me upon closer inspection whether the latter exclusion is actually deliberate or simply an implementation artifact (i.e., just epsilon more respectable than a bug) that could be relaxed with a small tweak. @erights needs to weigh in on this. |
Keys cannot contain promises, even for heap stores. Heap values can. I
think durable values must not. Our choice for virtual values, but I prefer
no promises there either. But, we can only omit virtual promises if we
support virtual notifiers and subscriptions by other means. Since the
latter will be high cardinality.
On Wed, Feb 9, 2022 at 11:28 AM Chip Morningstar ***@***.***> wrote:
With respect to durable data, the answer is a definite "no", at least with
respect to Promises per se, since promises don't survive the death and
resurrection of a vat. Obviously if you hold a presence to a remote object
that was imported, you can't actually tell if it's a promise on the remote
end or not, but at that point you don't care because the remote vat's
promise GC behavior is not your concern.
With respect to virtual data, it appears we *do* allow promises to be
used as values in virtual objects and stores, but not as keys in stores.
It's also not obvious to me upon closer inspection whether the latter
exclusion is actually deliberate or simply an implementation artifact
(i.e., just epsilon more respectable than a bug) that could be relaxed with
a small tweak. @erights <https://github.com/erights> needs to weigh in on
this.
—
Reply to this email directly, view it on GitHub
<#2485 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACC3TAR4IP3G42VLVTA5ADU2K557ANCNFSM4X4WX42Q>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
Cheers,
--MarkM
|
Per convo with Dean and Brian, we believe the answer is "NO". @warner please flesh this out. |
As stated, the answer is yes. But they can only be heap promises, and thus
|
@dtribble for follow on discussion. |
Current behavior:
Next step is for me to think about the problems I outlined and make some test cases
|
Leaving in MN-1 because this might enable GC nondeterminism from userspace. |
I think I understand the concerns better now. I await the answers to your next steps investigation. Thanks. |
#5106 addressed all of these problems. Virtual (i.e. merely-virtual, i.e. non-durable) objects and collections can hold Promises, but they consume RAM. Durable objects/collections cannot hold Promises. Now that #5106 is fixed, we don't |
What is the Problem Being Solved?
I suspect that putting a Promise into the
state
of a virtual object will cause problems, as would storing one in the value of aWeakStore
when the key is a virtual object. We should make sure this either works as expected, or is rejected clearly.We'll serialize the Promise when the
state.propname =
setter is invoked, or when theinit
/set
method on theWeakStore
is run. Our serialization code thinks it is only used to send things into the kernel, so it will attach a.then
, and when that fires, liveslots will do asyscall.resolve
into the kernel. However in this case, the kernel has not yet been told about the Promise, so the syscall will probably fail (it's a spurious/unwanted resolution).The
slotToVal
table will hold on to the actual Promise object until it gets resolved+retired, which in one sense fails to meet our memory-usage goals, but is necessary to retain the semantics (unresolved Promises do have an identity, and cannot be synthesized from plain data because we can't serialize anythen
callbacks that might be attached.. we can't even sense their existence). Rehydrating the virtual object, or doing aget
on theWeakStore
, will return the original Promise if it is still unresolved. If it is resolved, and thus retired, we need a place to track the resolved data, so the rehydrated version can be immediately resolved to the right state, rather than lingering forever as an unresolved promise.Description of the Design
Not sure yet, probably forbid them entirely, but maybe there's a clever way to serialize the necessary data.
In general I'm thinking our serialization code should return the capdata and let the caller decide what
.then
calls need to be done. Perhaps it should return a list of unresolved promises in addition to the capdata (as opposed to strictly returning the slots and letting the caller dig throughslotToVal
to find the original objects).Security Considerations
I suspect that any failures this could cause will be limited to the code that added the troublesome Promise. I don't expect it would spread beyond the original vat, or affect the kernel significantly. It might allow arbitrary code within a vat to kill the vat, if the spurious
syscall.resolve
is treated by the kernel as an illegal syscall.cc @FUDCo
The text was updated successfully, but these errors were encountered: