golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.22k stars 17.7k forks source link

testing/synctest: cross-bubble operations in wasm calls operations #70512

Open neild opened 16 hours ago

neild commented 16 hours ago

The following problem appears in https://go.dev/cl/630382.

syscall/js.FuncOf creates a function which may be called from JavaScript. syscall/fs_js.go (and probably other places) uses this mechanism to pass a callback to Javascript. The callback writes a value to a channel.

When running under synctest, this results in a cross-bubble channel operation: The channel is created in a synctest bubble, but the JS-executed function which sends to the channel runs outside the bubble, resulting in panic.

The fix might be to make syscall/js.FuncOf synctest-aware, so that callbacks run in the creators' bubble. But we'll also need to ensure that bubbles don't idle while a JS call is in progress. Possibly mark the bubble as active until FuncOf.Release is called?

ianlancetaylor commented 16 hours ago

CC @golang/wasm

gopherbot commented 14 hours ago

Change https://go.dev/cl/631055 mentions this issue: runtime, internal/synctest, syscall/js: keep bubble membership in syscalls