I'm developing a port of audio player to Mac environment. It works fine under windows, but not with Mac. I got an unpredictable deadlock when I'm playing the music with the player, the only information I can get is to dump the stack of threads of the hanging process. Here is the call stack I get:
Sampling process 1808 for 1 seconds with 1 millisecond of run time between samples
Sampling completed, processing symbols...
Analysis of sampling Python (pid 1808) every 1 millisecond
Call graph:
785 Thread_32664 DispatchQueue_1: com.apple.main-thread (serial)
785 0x1ea9
785 0x1f82
785 Py_Main
785 PyRun_SimpleFileExFlags
785 PyRun_FileExFlags
785 PyEval_EvalCode
785 PyEval_EvalCodeEx
785 PyEval_EvalFrameEx
785 time_sleep
785 select
785 select$DARWIN_EXTSN$NOCANCEL
785 Thread_32672 DispatchQueue_2: com.apple.libdispatch-manager (serial)
785 start_wqthread
785 _pthread_wqthread
785 _dispatch_worker_thread2
785 _dispatch_queue_invoke
785 _dispatch_mgr_invoke
785 kevent
785 Thread_32679
785 thread_start
785 _pthread_start
785 CAPThread::Entry(CAPThread*)
785 HP_IOThread::ThreadEntry(HP_IOThread*)
785 HP_IOThread::WorkLoop()
785 HP_IOThread::PerformIO(AudioTimeStamp const&, double)
785 IOA_Device::CallIOProcs(AudioTimeStamp const&, AudioTimeStamp const&, AudioTimeStamp const&)
785 HP_IOProc::Call(AudioTimeStamp const&, AudioTimeStamp const&, AudioBufferList const*, AudioTimeStamp const&, AudioBufferList*)
785 BASS_ChannelIsSliding
785 MPEnterCriticalRegion
785 TSWaitOnConditionTimedRelative
785 TSWaitOnCondition
785 pthread_cond_wait$UNIX2003
785 _pthread_cond_wait
785 __semwait_signal
785 Thread_32680
785 0xa4fffad
785 dict_repr
785 0x1307ccd
785 MPEnterCriticalRegion
785 TSWaitOnConditionTimedRelative
785 TSWaitOnCondition
785 pthread_cond_wait$UNIX2003
785 _pthread_cond_wait
785 __semwait_signal
785 Thread_32681
785 MPEnterCriticalRegion
785 TSWaitOnConditionTimedRelative
785 TSWaitOnCondition
785 pthread_cond_wait$UNIX2003
785 _pthread_cond_wait
785 __semwait_signal
785 Thread_36905
785 start_wqthread
785 _pthread_wqthread
785 __workq_kernreturn
Total number in stack (recursive counted multiple, when >=5):
Sort by top of stack, same collapsed (when >= 5):
__semwait_signal 2355
__workq_kernreturn 785
kevent 785
select$DARWIN_EXTSN$NOCANCEL 785
Sample analysis of process 1808 written to file /dev/stdout
I can only know some threads are waiting for others, but I have no idea what locks they are, who is waiting for. Here comes my question, how can I debug the deadlock under Mac environment?