Michael,
Here is a Go solution to the OP's problem. It uses Go memory and Go
pointers passed to C in Go memory point to pinned Go memory.
https://go.dev/play/p/KLdenIesz1K
Peter
On Monday, January 29, 2024 at 12:21:18 PM UTC-5 Michael Knyszek wrote:
> Thanks for the reproducer. I think I've p
Thanks for the reproducer. I think I've puzzled out what's going wrong and
it's pretty subtle.
TL;DR: You can work around this by either calling `calloc` or just
allocating `inRows` as Go memory and pinning that as well. The latter will
be safer and faster overall. It's not totally clear to me at
Michael,
The OP appears to have lost interest in debugging. Here's my minimal,
reproducible example that produces the same fatal errror:
https://go.dev/play/p/flEmSh1euqR (run locally)
If the runtime.GC() statement is uncommented then the fatal error does not
occur.
The use of this profli
Ignoring more efficient ways to pass memory to C for a moment,
superficially I do think your code using Pinner should work. Do you have a
full reproducer? It's hard to tell from just looking at your code if your
code is the problem, or its just enough to trigger some other cgo issue
elsewhere i
To convert a Go slice to C array is easy with unsafe.Slice.
The problem is that the multi-dimensional C array is an array of pointers
(*(*float64))
which cannot travel between the C/Go barrier.
In your example, you flatten your slice, and recreate the pointers in that
one big slice.
You could g