pthread_cond_signal deadlocks

岁酱吖の 提交于 2019-12-12 01:27:17

问题


What could be the cause if a call to pthread_cond_signal deadlocks?

From what I understand (man page), it is implemented internally with a mutex, but what could cause this internal mutex lock operation to deadlock?

EDIT: I am debugging an application which seem to deadlock on some occasions. A few of the stacktraces look like this:


Thread 1 (Thread 0xf6dff6c0 (LWP 32001)):
#0  0xffffe410 in __kernel_vsyscall ()
#1  0x00af15de in __lll_mutex_lock_wait () from /lib/tls/libpthread.so.0
#2  0x00aef3eb in pthread_cond_signal@@GLIBC_2.3.2 () from /lib/tls/libpthread.so.0
#3  0xf4cc8d83 in xxx

回答1:


Well, one thing to look for might be this caveat from the man page, which sounds particularly applicable:

The condition functions are not async-signal safe, and should not be called from a signal handler. In particular, calling pthread_cond_signal or pthread_cond_broadcast from a signal handler may deadlock the calling thread.

Apart from that, you could also see this if the internal mutex within the pthread_cond_t has been overwritten by a stray write beyond the bounds of some other variable.



来源:https://stackoverflow.com/questions/4345315/pthread-cond-signal-deadlocks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!