So how should I debug this situation?
Usually you can catch the bug easily by writing control messages to stdout. For example:
std::cout << "*1" << std::flush;
... some code that perhaps throws a sigsegv
std::cout << "*2" << std::flush;
then launch PI from a terminal window. If you get this on the terminal:
*1*2
you know the problem is not within the code you are testing. However if you get only:
*1
before the exception, then you've catched it. If necessary, repeat this technique to stretch the code more and more until you get the offending bit. I use this technique and it helps me catch all bugs in the 98% of situations. Note that the calls to std::flush are essential here; without them, buffered output makes the testing code useless.
For the remaining 2%, I strongly recommend you create an Eclipse project for your module and launch the PixInsight Core application to start an interactive GDB session.
Good luck!