if you're running it on linux && standard glibc, you can try exporting environment variable MALLOC_CHECK=3 (or MALLOC_CHECK_). This should add debug hooks to malloc and free.

But you should really try debugger. On linux you can let the program run till the deadlock, and then attach the gdb to the process. On threaded environment it may also be caused by semaphores or mutexes.