v8worker2
v8worker2 copied to clipboard
Allocating a few MB in V8Worker2.recv crashes when looping worker.SendBytes
Run this test app:
main.go
package main
import (
"github.com/ry/v8worker2"
)
func main() {
worker := v8worker2.New(func(msg []byte) []byte {
return nil
})
err := worker.Load("codeWithRecv.js", `
V8Worker2.recv(function(msg) {
var data = new ArrayBuffer(5600000)
})
`)
if err != nil {
panic(err)
}
for i := 0; i <= 1000; i++ {
err = worker.SendBytes([]byte(`test`))
if err != nil {
panic(err)
}
}
}
Throws this exception:
main(56725,0x70001067a000) malloc: *** error for object 0x60028e0: pointer being freed was not allocated
main(56725,0x70001067a000) malloc: *** set a breakpoint in malloc_error_break to debug
signal: abort trap
Platform: macOS 10.14.2
Note: built against v8 6.9.427.19 as suggested here: https://github.com/ry/v8worker2/issues/22