Having a stupid error where the compiler is somehow not linking up the pthread mutex libraries even though pthread.h is included and compiling with -pthread and -lpthread. Initially the problem was trylock was not being found, but lock is not as well. I'm assuming that unlock would not as well if it got to it before segfaulting.