joellubi commented on issue #1841:
URL: https://github.com/apache/arrow-adbc/issues/1841#issuecomment-2110414431

   I've been doing some research into this and came across the following 
library: [gopy](https://github.com/go-python/gopy/tree/master). It's meant to 
generate and compile CGO and CPython extensions from a Go package. What's 
specifically interesting about it is the unique-handler approach it uses to 
avoid passing Go pointers directly to C. There's a brief description in the 
README and the actual handler implementation is in 
[handler.go](https://github.com/go-python/gopy/blob/master/gopyh/handle.go).
   
   I'm still wrapping my head around what a specific implementation would look 
like, but I wonder if we could adopt a similar approach to isolate pointers 
within their respective Go runtimes. The actual memory we do want to share 
(arrays) should be allocated in C anyway via the CGO Mallocator, and with an 
approach like this all Go pointers are only accessed within the Go runtime via 
stub methods that delegate the actions to be done.
   
   It's not super obvious how it does all this just by looking at the source 
code, but if you look at the code generated by running the "command line 
example" in the readme it makes the mechanism clearer.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to