Skip to content
This repository has been archived by the owner on Oct 19, 2019. It is now read-only.

Exception after calling Dispose() or after worker GC #27

Open
gshahbazian opened this issue Jan 8, 2019 · 0 comments
Open

Exception after calling Dispose() or after worker GC #27

gshahbazian opened this issue Jan 8, 2019 · 0 comments

Comments

@gshahbazian
Copy link

Run this test app:

main.go

package main

import (
	"fmt"

	"github.com/ry/v8worker2"
)

func main() {
	for i := 1; i <= 10; i++ {
		fmt.Println("create worker", i)

		recvCount := 0
		worker := v8worker2.New(func(msg []byte) []byte {
			if len(msg) != 5 {
				fmt.Println("bad msg", msg)
				panic("")
			}
			recvCount++
			return nil
		})

		err := worker.Load("codeWithRecv.js", `
			V8Worker2.recv(function(msg) {
				V8Worker2.print("TestBasic recv byteLength", msg.byteLength);
				if (msg.byteLength !== 3) {
					throw Error("bad message");
				}
			});
		`)
		if err != nil {
			panic(err)
		}
		err = worker.SendBytes([]byte("hii"))
		if err != nil {
			panic(err)
		}
		codeWithSend := `
			V8Worker2.send(new ArrayBuffer(5));
			V8Worker2.send(new ArrayBuffer(5));
		`

		err = worker.Load("codeWithSend.js", codeWithSend)
		if err != nil {
			panic(err)
		}

		if recvCount != 2 {
			fmt.Println("bad recvCount", recvCount)
			panic("")
		}

		worker.TerminateExecution()
		worker.Dispose()
	}
}


Throws this exception:

create worker 1
TestBasic recv byteLength 3
main(52501,0x1226d5c0) malloc: *** error for object 0x8002470: pointer being freed was not allocated
main(52501,0x1226d5c0) malloc: *** set a breakpoint in malloc_error_break to debug
SIGABRT: abort
PC=0x7fff5a5e923e m=0 sigcode=0

goroutine 0 [idle]:
runtime: unknown pc 0x7fff5a5e923e
stack: frame={sp:0x7ffeefbff658, fp:0x0} stack=[0x7ffeefb80988,0x7ffeefbff9f0)
00007ffeefbff558:  0000000000000000  00007fff5a679b1e 
00007ffeefbff568:  00007ffeefbff5b8  00007ffeefbff5e0 
00007ffeefbff578:  00000000053fc000  000000001226d5c0 
00007ffeefbff588:  00007ffeefbffbe4  00007fff5a679aa9 
00007ffeefbff598:  0000000000000050  00007ffeefbff680 
00007ffeefbff5a8:  00007fff5a693085  0000003000000018 
00007ffeefbff5b8:  00007ffeefbff690  00007ffeefbff5d0 
00007ffeefbff5c8:  00007fff5a6931d9  0000000000000000 
00007ffeefbff5d8:  0000000000000050  00007fff5a679aa9 
00007ffeefbff5e8:  00000000053fc047  0000000000000000 
00007ffeefbff5f8:  0000000000000000  00007ffeefbff7e8 
00007ffeefbff608:  00007ffeefbff678  0000000000000000 
00007ffeefbff618:  00000000053fb000  00007ffeefbff648 
00007ffeefbff628:  0000000000000050  00007fff8d292240 
00007ffeefbff638:  00007fff8d291ca0  00007fff5a53148c 
00007ffeefbff648:  0000000000000000  00007ffeefbff690 
00007ffeefbff658: <00007fff5a69fc1c  000000001226d5c0 
00007ffeefbff668:  00007ffeefbff6a8  0000000000000000 
00007ffeefbff678:  00000000053fb000  0000000000000000 
00007ffeefbff688:  0000000000000050  00007ffeefbff6c0 
00007ffeefbff698:  00007fff5a5521c9  00007fff8d2a260c 
00007ffeefbff6a8:  00000000ffffffdf  ffffffff00000000 
00007ffeefbff6b8:  00000000053fb028  00007ffeefbff720 
00007ffeefbff6c8:  00007fff5a6616e2  0000000000000000 
00007ffeefbff6d8:  000000001226d5c0  00007ffeefbff7e0 
00007ffeefbff6e8:  0000000000000000  00007fff5a677a5b 
00007ffeefbff6f8:  0000000008014720  000000000000000a 
00007ffeefbff708:  0000000008003000  0000000008014720 
00007ffeefbff718:  0000000000000003  00007ffeefbff800 
00007ffeefbff728:  00007fff5a6614a3  00007ffeefbff7c0 
00007ffeefbff738:  00007fff5a65bb54  0000000008002470 
00007ffeefbff748:  00000000053aba00  0000000008000000 
runtime: unknown pc 0x7fff5a5e923e
stack: frame={sp:0x7ffeefbff658, fp:0x0} stack=[0x7ffeefb80988,0x7ffeefbff9f0)
00007ffeefbff558:  0000000000000000  00007fff5a679b1e 
00007ffeefbff568:  00007ffeefbff5b8  00007ffeefbff5e0 
00007ffeefbff578:  00000000053fc000  000000001226d5c0 
00007ffeefbff588:  00007ffeefbffbe4  00007fff5a679aa9 
00007ffeefbff598:  0000000000000050  00007ffeefbff680 
00007ffeefbff5a8:  00007fff5a693085  0000003000000018 
00007ffeefbff5b8:  00007ffeefbff690  00007ffeefbff5d0 
00007ffeefbff5c8:  00007fff5a6931d9  0000000000000000 
00007ffeefbff5d8:  0000000000000050  00007fff5a679aa9 
00007ffeefbff5e8:  00000000053fc047  0000000000000000 
00007ffeefbff5f8:  0000000000000000  00007ffeefbff7e8 
00007ffeefbff608:  00007ffeefbff678  0000000000000000 
00007ffeefbff618:  00000000053fb000  00007ffeefbff648 
00007ffeefbff628:  0000000000000050  00007fff8d292240 
00007ffeefbff638:  00007fff8d291ca0  00007fff5a53148c 
00007ffeefbff648:  0000000000000000  00007ffeefbff690 
00007ffeefbff658: <00007fff5a69fc1c  000000001226d5c0 
00007ffeefbff668:  00007ffeefbff6a8  0000000000000000 
00007ffeefbff678:  00000000053fb000  0000000000000000 
00007ffeefbff688:  0000000000000050  00007ffeefbff6c0 
00007ffeefbff698:  00007fff5a5521c9  00007fff8d2a260c 
00007ffeefbff6a8:  00000000ffffffdf  ffffffff00000000 
00007ffeefbff6b8:  00000000053fb028  00007ffeefbff720 
00007ffeefbff6c8:  00007fff5a6616e2  0000000000000000 
00007ffeefbff6d8:  000000001226d5c0  00007ffeefbff7e0 
00007ffeefbff6e8:  0000000000000000  00007fff5a677a5b 
00007ffeefbff6f8:  0000000008014720  000000000000000a 
00007ffeefbff708:  0000000008003000  0000000008014720 
00007ffeefbff718:  0000000000000003  00007ffeefbff800 
00007ffeefbff728:  00007fff5a6614a3  00007ffeefbff7c0 
00007ffeefbff738:  00007fff5a65bb54  0000000008002470 
00007ffeefbff748:  00000000053aba00  0000000008000000 

goroutine 1 [syscall]:
runtime.cgocall(0x4096390, 0xc000055e90, 0x8)
	/usr/local/Cellar/go/1.11.4/libexec/src/runtime/cgocall.go:128 +0x5e fp=0xc000055e60 sp=0xc000055e28 pc=0x40045be
github.com/ry/v8worker2._Cfunc_worker_dispose(0x8001e30)
	_cgo_gotypes.go:125 +0x41 fp=0xc000055e90 sp=0xc000055e60 pc=0x4094591
github.com/ry/v8worker2.(*Worker).Dispose.func1(0x8001e30)
	/Users/gabeshahbazian/development/go/src/github.com/ry/v8worker2/worker.go:194 +0x56 fp=0xc000055ec8 sp=0xc000055e90 pc=0x4095736
github.com/ry/v8worker2.(*Worker).Dispose(0xc0000101f0)
	/Users/gabeshahbazian/development/go/src/github.com/ry/v8worker2/worker.go:194 +0x98 fp=0xc000055ef8 sp=0xc000055ec8 pc=0x40950b8
main.main()
	/Users/gabeshahbazian/development/go/src/github.com/gshahbazian/v8test/main.go:54 +0x52 fp=0xc000055f98 sp=0xc000055ef8 pc=0x4095dd2
runtime.main()
	/usr/local/Cellar/go/1.11.4/libexec/src/runtime/proc.go:201 +0x207 fp=0xc000055fe0 sp=0xc000055f98 pc=0x402b277
runtime.goexit()
	/usr/local/Cellar/go/1.11.4/libexec/src/runtime/asm_amd64.s:1333 +0x1 fp=0xc000055fe8 sp=0xc000055fe0 pc=0x4053851

rax    0x0
rbx    0x1226d5c0
rcx    0x7ffeefbff658
rdx    0x0
rdi    0x307
rsi    0x6
rbp    0x7ffeefbff690
rsp    0x7ffeefbff658
r8     0x0
r9     0x7ffeefbff5b0
r10    0x0
r11    0x206
r12    0x307
r13    0x53fb000
r14    0x6
r15    0x2d
rip    0x7fff5a5e923e
rflags 0x206
cs     0x7
fs     0x0
gs     0x0
exit status 2

Platform: macOS 10.14.2

Note: built against v8 6.9.427.19 as suggested here: #22

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant