21:23
<iain>
Working on implementing Atomics.waitAsync: the spec text doesn't appear to say anything about what happens to a WaiterRecord if the agent that called waitAsync to create it terminates before it is notified. My initial expectation is that it would be removed from the WaiterList, but testing Chrome's implementation seems to indicate that there's still an entry
21:24
<iain>
(Methodology: create two workers, each of which calls Atomics.waitAsync on the same location, then terminate the first one. Atomics.notify has to be called twice to resolve the promise in the second worker, implying that the first worker's WaiterRecord is still hanging around)
21:25
<iain>
Is this the intended behaviour?
22:58
<shu>
yes, this is unfortunately a known leak
22:58
<shu>
i think there's some kind of lazy sweeping
22:59
<shu>
as for what the specified semantics are, i think it is currently underspecified. ecma262 doesn't really have a concept of "agent terminated"
23:02
<shu>
it's not clear to me right now how easy it is to do this kind of sweeping eagerly
23:02
<shu>
iain: can it be done in Firefox easily?
23:02
<shu>
i agree with your intuition, it'd be nice if terminated agents made those entries disappear
23:02
<shu>
but like, how do you define when it's terminated?
23:05
<iain>
shu: I don't have any of it working yet in Firefox, so it's hard to say for sure how difficult it would be
23:05
<iain>
I thought I had a plan for clearing entries out when the runtime was shut down, but as I type this I realize that my current design only handles entries with an associated timeout
23:09
<iain>
But in any case, we already have code that cleans up when the runtime/context goes away: https://searchfox.org/mozilla-central/source/js/src/vm/JSContext.cpp#221
23:11
<iain>
In my test I just used worker.terminate()
23:22
<iain>
Actually, I don't understand why this code in V8 doesn't already clean out the waiter when the isolate for the terminated worker thread goes away
23:48
<shu>
huh, that's a good question
23:48
<shu>
it's been a while, could you please file an issue if you have a testcase handy?