sourcegraph / go-webkit2

WebKit API bindings (WebKitGTK+ v2) for Go
https://sourcegraph.com/github.com/sourcegraph/go-webkit2
Other
313 stars 61 forks source link

Memory managed by Go can't be passed to C as of Go 1.6 #35

Closed paultag closed 7 years ago

paultag commented 7 years ago

Discussion at:

https://github.com/golang/go/issues/12416
https://github.com/golang/proposal/blob/master/design/12416-cgo-pointers.md

Issues with the Go memory management code were hacked around by adding a new check that ensured that pointers to memory managed by Go are never passed to cgo code, since one can not be sure how and where pointers to Go memory are being stored in the C code.

As a result, the memory must be manually malloc'd and free'd by cgo, even if it's a Go object in the C memory. The userdata fix makes this change explicit, by running a malloc and free using cgo, to explicitly control the memory management.

paultag commented 7 years ago

Thank you!