Closed
Description
What version of Go are you using (go version
)?
$ go version go version go1.14.1 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/Users/hajimehoshi/Library/Caches/go-build" GOENV="/Users/hajimehoshi/Library/Application Support/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/hajimehoshi/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/ht/ky_bwgzs4bd5z1hh02k34x_h0000gn/T/go-build937690981=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
Build this Go program as Wasm and run it on a browser several times:
package main
import (
"fmt"
"time"
)
func main() {
ch1 := make(chan string)
ch2 := make(chan string)
ch3 := make(chan struct{})
go func() {
for {
time.Sleep(5 * time.Millisecond)
ch1 <- "A"
}
}()
go func() {
for {
time.Sleep(7 * time.Millisecond)
ch2 <- "B"
}
}()
go func() {
for {
time.Sleep(3 * time.Second)
close(ch3)
}
}()
loop:
for {
select {
case str := <-ch1:
fmt.Println(str)
case str := <-ch2:
fmt.Println(str)
case <-ch3:
fmt.Println("Done")
break loop
}
}
}
What did you expect to see?
No error (except for 'already exit')
What did you see instead?
Sometimes I saw this error:
Uncaught RuntimeError: memory access out of bounds
at runtime.__waitq_.dequeue (wasm-function[113]:0xbe09)
at runtime.chanrecv (wasm-function[109]:0xab34)
at runtime.chanrecv1 (wasm-function[108]:0xa89b)
at syscall.fsCall (wasm-function[1636]:0x12510e)
at syscall.Write (wasm-function[1634]:0x12471b)
at internal_poll.__FD_.Write (wasm-function[1657]:0x128d1e)
at os.__File_.Write (wasm-function[1669]:0x129ef2)
at fmt.Fprintln (wasm-function[1700]:0x131eb1)
at main.main (wasm-function[1720]:0x14065c)
at wasm_pc_f_loop (wasm-function[950]:0xc3a5f)
| runtime.__waitq_.dequeue | @ | 008b857e-113:116
| runtime.chanrecv | @ | 008b857e-109:249
| runtime.chanrecv1 | @ | 008b857e-108:37
| syscall.fsCall | @ | 008b857e-1636:354
| syscall.Write | @ | 008b857e-1634:451
| internal_poll.__FD_.Write | @ | 008b857e-1657:385
| os.__File_.Write | @ | 008b857e-1669:164
| fmt.Fprintln | @ | 008b857e-1700:170
| main.main | @ | 008b857e-1720:471
| wasm_pc_f_loop | @ | 008b857e-950:14
| wasm_export_resume | @ | 008b857e-949:5
| _resume | @ | wasm_exec.js:544
| (anonymous) | @ | wasm_exec.js:308
| setTimeout (async) | |
| runtime.scheduleTimeoutEvent | @ | wasm_exec.js:306
| runtime.scheduleTimeoutEvent | @ | 008b857e-969:6
| runtime.beforeIdle | @ | 008b857e-158:107
| runtime.findrunnable | @ | 008b857e-564:1278
| runtime.schedule | @ | 008b857e-569:960
| runtime.park_m | @ | 008b857e-572:245
| runtime.mcall | @ | 008b857e-899:77
| runtime.gopark | @ | 008b857e-515:312
| runtime.selectgo | @ | 008b857e-655:2335
| main.main | @ | 008b857e-1720:349
| wasm_pc_f_loop | @ | 008b857e-950:14
| wasm_export_resume | @ | 008b857e-949:5
| _resume | @ | wasm_exec.js:544
| (anonymous) | @ | wasm_exec.js:308
...