Debugger tells you where your shit crashed, and lets you see which variable is at fault.
Also, wrap your printf something like this:
#define dbg(fmt, ...) dprintf(STDERR_FILENO, "%s:%d " fmt "\n", strstr(__FILE__, "src/"), __LINE__ __VA_OPT__(,) __VA_ARGS__);