A memory debugging tool like Valgrind is well suited to this, though it's a fair amount of work to get this up and running. You might just run it through gdb and see where you are when it crashes.