Question on jl_alloc_array_2d seg fault

Hi, I am interested in building a Go interface to Julia (for simple data passing and function evals) and having issues with jl_alloc_array_2d. In particular, repeated use of this function seems to intermittently lead to following seg fault:

signal (11): Segmentation fault
in expression starting at none:0
Allocations: 2722 (Pool: 2713; Big: 9); GC: 0

My use cases are very simple and in this particular example I am passing a 7x7 float64 data to Julia. The function mostly runs fine except that I get the above seg fault error once in a while.

I am wondering if there are recommendations on how to use memory allocation functions in Julia’s C interface? Thanks.

Can you share an example of what code you’re actually running when encountering this issue? I’m afraid the information you’ve provided is not enough to help diagnose it.

it’s almost certainly GC, both Go and Julia has a GC so it’s really annoying to make them play if you pass data back and forth

1 Like

Hi @Sukera it is a Go test where I am passing native Go data to a go-routine running Julia. It is in that go-routine where memory allocation of a 2D array of float64 data type happens. Currently that is the only operation I am testing, however, goal is to able to run just one go-routine with Julia embedded in it and have all other go-routines pass data to it.

In the past I ran into seg-fault issues where Julia was not safe to run in multiple go-routines with the requirements that all threads must be started by Julia runtime and not the foreign caller. It is for this reason why I am trying to isolate Julia related cgo calls to one go-routine.

hi @jling, yes that is true and its been an issue in the past Problems scaling jl_alloc_array_2d C API
Considering my use cases are very simple I am hoping to arrive at a workflow where code is robust.