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

Go 1.6 is more strict: cgo argument has Go pointer to Go pointer #31

Closed
emicklei opened this issue Jan 31, 2016 · 5 comments
Closed

Go 1.6 is more strict: cgo argument has Go pointer to Go pointer #31

emicklei opened this issue Jan 31, 2016 · 5 comments

Comments

@emicklei
Copy link
Contributor

Today, at FOSDEM in Brussel, I learned about a new compiler change regarding the use of pointers in cgo. Wondering if this would affect v8worker, I tried building the project using 1.6rc1. I hope we can find a way to play by the new rules.

panic: runtime error: cgo argument has Go pointer to Go pointer [recovered]
    panic: runtime error: cgo argument has Go pointer to Go pointer

goroutine 5 [running]:
testing.tRunner.func1(0xc820090000)
    /usr/local/go/src/testing/testing.go:467 +0x192
github.com/ry/v8worker._cgoCheckPointer0(0xb80740, 0xc82000a140, 0x0, 0x0, 0x0, 0x0)
    github.com/ry/v8worker/_obj/_cgo_gotypes.go:58 +0x4d
github.com/ry/v8worker.New(0xc8200105b0, 0xc8200105c0, 0xc820012390)
    /go/src/github.com/ry/v8worker/worker.go:70 +0xe2
bitbucket.org/emicklei/v8dispatcher.NewMessageDispatcher(0x0)
    /go/src/bitbucket.org/emicklei/v8dispatcher/dispatcher.go:34 +0x18c
@emicklei
Copy link
Contributor Author

Actually, this output is from running the tests of v8dispatcher (that uses v8worker). I will try a build of v8worker now.

@emicklei
Copy link
Contributor Author

@emicklei
Copy link
Contributor Author

emicklei commented Feb 1, 2016

As described in the previous discussions (see links), a workaround is to use GODEBUG=cgocheck=0

@ry
Copy link
Owner

ry commented Feb 3, 2016

I guess this is caused by storing a pointer to the Go worker object in the data field of the C worker object.

worker.cWorker = C.worker_new(callback, receiveSync_callback, unsafe.Pointer(worker))

We don't need to do this - the data object is opaque to the C code. We could use some sort of look up table in the golang side to store all the workers and just send a key (an integer?) to the C code. I'll try to do this now.. writing this out in case I get distracted and don't finish.

@emicklei
Copy link
Contributor Author

emicklei commented Feb 3, 2016

I was thinking about putting the callbacks in some registry to avoid having pointer values inside the worker struct (the map-registry approach as mentioned in the issue).
Your suggestion sounds much simpler.

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

2 participants