Interrupting and debugging an OCaml process

Occasionally an OCaml process in our use runs away. I can hit both
a byte compiled and a native compiled version of it with a signal and get a core dump (on Ubuntu 22+).

But I can’t read anything from a byte compiled core file in ocamldebug nor a native in gdb.

Is this possible and if so how?

I’d be surprised if there is a tool to reconstruct the bytecode compiled core dump. Essentially you’re running the bytecode machine (written in C) interpreting the OCaml bytecode. To use the bytecode debugger ocamldebug you’d need to launch your process from within the debugger.

For GDB it should be possible to work with a native compiled program. It would need to be compiled with -g to include debug information. Which version of OCaml are you using?

Another option would be using perf CPU profiling to see where it’s spending all its time. A busy loop would turn up in the flame graph of time spent.