I am not sure what is wrong with the UDF but I know that SIGSEGV error occurs when the code tries to access a location in the memory that was not declared. This happens usually with vectors when you try to access the index beyond the vector length.n