2013-11-01 38 views
0

我的問題gdb的輸出:僵局pthread_cond_destroy()在

Program received signal SIGINT, Interrupt. 0x00007ffff7bcb86b in 
__lll_lock_wait_private() from /lib/x86_64-linux-gnu/libpthread.so.0 (gdb) bt 
#0 0x00007ffff7bcb86b in __lll_lock_wait_private() from /lib/x86_64-linux-gnu/libpthread.so.0 
#1 0x00007ffff7bc8bf7 in _L_lock_21() from /lib/x86_64-linux-gnu/libpthread.so.0 
#2 0x00007ffff7bc8a6e in [email protected]@GLIBC_2.3.2() from /lib/x86_64-linux-gnu/libpthread.so.0 
#3 0x0000000000400ab5 in control_destroy (mycontrol=0x6020c0) at control.c:20 
#4 0x0000000000400f36 in cleanup_structs() at workcrew.c:160 
#5 0x0000000000401027 in main() at workcrew.c:201 

注:在Cygwin中成功運行的程序,但在Ubuntu Linux操作系統,它的僵局運行。 所有子線程在死鎖之前連接完成。

的源代碼是從網頁:http://www.ibm.com/developerworks/cn/linux/thread/posix_thread3/thread-3.tar.gz

回答

1

該缺陷是在control.c

int control_destroy(data_control *mycontrol) { 
    int mystatus; 
    if (pthread_cond_destroy(&(mycontrol->cond))) 
    return 1; 
    if (pthread_cond_destroy(&(mycontrol->cond))) 
    return 1; 
    mycontrol->active=0; 
    return 0; 
} 

這是,據推測,應該破壞互斥和條件變量。但相反,它將兩次破壞條件變量。

+0

好的,非常感謝 – user2944046