On Wed, Dec 4, 2019 at 6:48 AM Robert Johnstone <r.w.johnst...@gmail.com> wrote: > > Thanks for the quick reply. I had not considered the write barriers, but if > the Go objects are "live" longer than the held in C, it would work.
The write barriers do not look only at the pointer being stored, they also look at the contents of memory being stored into. That is why C code must never store a Go pointer into Go memory. > I definitely agree that there are risks associated with this approach. We > are giving up some of the safety of Go. Unfortunately, we are using cgo for > more than some computation, so we have live objects in C as well, and so we > cannot completely escape the manual memory management required. > > What is the state of plans for a moving garbage collector? This would > definitely wreck havoc if any pointers to Go memory were held in C. There are no current plans for a moving garbage collector. I cannot promise that no other changes will break this approach. Obviously we won't consider bug reports for code that breaks the cgo rules. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXq9k%2BzKd28Ff0fDQQYvbSC01fQnpxWe7Lk%3Djdaddtghg%40mail.gmail.com.