How to debug a silent crash?

I’m writing a script which calls a C library and the program is just stopping prematurely with no output.

How do I debug this?

A little context:
I’m passing a Julia function as a callback to the SimpleBLE C library that is called when data is received from a Bluetooth device. The callback is called once and seems to execute successfully and a few seconds later the process stops.
The callback contains an unsafe_wrap to read the incoming data, then calls println to display it and finally calls the library’s free function on the received data.

Is julia garbage collecting the callback closure? You may need to setup some GC preserve.