# Segfault calling into Julia from C/MPI

**URL:** <https://discourse.julialang.org/t/segfault-calling-into-julia-from-c-mpi/124800>\
**Category:** General Usage\
**Tags:** question\
**Created:** [January 15, 2025, 5:33pm UTC](https://discourse.julialang.org/t/segfault-calling-into-julia-from-c-mpi/124800 "2025-01-15T17:33:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![liamh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liamh/32/208541_2.png) [@liamh](https://discourse.julialang.org/u/liamh)\
**Post date:** [January 15, 2025, 5:33pm UTC](https://discourse.julialang.org/t/segfault-calling-into-julia-from-c-mpi/124800/1 "2025-01-15T17:33:15Z")

</div>

I have written a Julia package and compiled a shared object library to call one `@ccallable` function. When I test it with a serial C program, it works fine. When I call it from a more complex program using MPI (even when run with `-np 1`), it segfaults in `libc.so.6`.

```julia
Thread 1 "compute-density" received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()

```

I can use `gdb` to find where this is happening, but I get no information from the Julia part; the last meaningful information I get is where the C program called the Julia function.

Is there anything special that I need to do building the library so that it can be called from MPI? Is there any way to enable `gdb` to give me Julia information (line numbers, variable values, etc.)?

---

<div class="post-metadata">

**Author:** ![liamh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liamh/32/208541_2.png) [@liamh](https://discourse.julialang.org/u/liamh)\
**Post date:** [January 16, 2025, 3:12pm UTC](https://discourse.julialang.org/t/segfault-calling-into-julia-from-c-mpi/124800/2 "2025-01-16T15:12:14Z")

</div>

I found the cause, I had failed to include the `init_julia()` call at the start of the C program. It would still be nice know how to use `gdb` in a Julia library running in C.
