Segmentation error, Garbage Collection

question
embedding

#1

What I’m trying to do is to implement a complete interface to call any function of Julia from Scilab language.
I think the problem is in garbage collection. I would like to know whether there are any such problems. And also I would like to know in detail about how to do Garbage Collection.

Thank you.

The error is:

while loading no file, in expression starting on line 0
Segmentation fault (core dumped)```


https://github.com/tastelessjolt/scilab-julia-interface/blob/master/sci_call_julia.c
https://github.com/tastelessjolt/scilab-julia-interface/blob/master/double_conv.c
https://github.com/tastelessjolt/scilab-julia-interface/blob/master/integer_conv.c

#2

For one thing, jl_init and jl_atexit_hook can only be called once. It is illegal to call it on every call. GC interaction is described in the embedding doc and from a very breif glance it seems to be ok.


#3

Yeah, I tried separating the init and exit calls by adding functions so that jl_init and jl_atexit_hook will be called only once in the lifetime of the program. But still it does give the segmentation error. Since, it gives the segmentation error after calling the function or while it is idle, I couldn’t pinpoint which part of the code is giving the segmentation error.
So, what might have been going wrong?

Thank you.


#4

Anything can go wrong. It’s very hard to tell even with the code but if it segfault when julia is not running and it seems that you are not holding any reference to julia object it probably happen either because wrong use of scilab API or conflict in signal handling.


#5

Might be.
Btw, What do you mean by signal handling?

And also does this help that once the libraries are loaded, the virtual memory becomes ~ 11GB? I know that it doesn’t matter much but just in case.

Thank you.


#6

I mean, well, handling signals… Like if scilab uses signals to do something.

This is expected.


#7

And also it is that sometimes just calling the jl_init leads to segmentation fault.
What might lead jl_init to a segmentation fault?


#8

You should get a backtrace. If julia didn’t give you one you should attach a debugger.


#9

And update, if I use scilab’s cli, then it works with no problem, but problem is only when I use it with GUI if that helps in some way.