This is a common symptom if the argument marshalling goes wrong.
Wrap C routines into a library, and link it to a C driver
which calls the routines. And it executes without any problem.
But using the same library, write the required glue XS code, then
link it together to create a shared module. Load the module
and call the function. Coredump.