Something is wrong with the program, at a very basic level. The only observable effect is that it crashes, now what do you do?
If your program interacts at all with the operating system, then you have a great option: strace. strace
is a command that attaches to a program and logs every system call that the program makes. You can filter the output to look for very specific types of calls, or step through the logs to see very granular progressive behavior of any program.
For me, the problem that I encountered was that I was hardcoding system call numbers that I found online. Linux has different system call numbers for different architectures, and the specific call numbers are hidden away in some C header file on the system. Putting strace onto my program immediately showed me that the system call was malformed. Easy fix.
Next time that you need to log a simple, or even fairly complex, program, consider trying out strace. It can provide great insight when you need it.