It appears that the random crashes have been fixed. I wasn't locking up the state between the multiple threads.
added cppcheck command in the makefile