[英]How to debug a deadlock under mac osx?
I'm developing a port of audio player to Mac environment. 我正在将音频播放器移植到Mac环境。 It works fine under windows, but not with Mac.
它在Windows下工作正常,但不适用于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?
我的问题来了,如何在Mac环境下调试死锁?
Debugging multi-threaded apps is inherently difficult. 调试多线程应用程序本质上是困难的。 A simple (and possibly simplistic ) approach is to write all of your lock about-to-grab/blocked/released events to a log file.
一种简单(可能是简单化 )的方法是将所有锁即将捕获/阻止/释放的事件写入日志文件。 Nothing particularly OS X about that, but I've used it to good effect on similar problems.
关于OS X并没有什么特别的,但是我已经使用它在类似问题上取得了很好的效果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.