類LocalT
擁有其他類的成員,它們實現了read-write-mutex
。互斥體在構造函數初始化並使用pthread_rwlock_rdlock(&aMutex);
進行讀取鎖定。所以,看來,它與互斥類完全一樣。但是當一些對象鎖定他的互斥成員閱讀時,程序崩潰了。C++ pthreads - 嘗試鎖定互斥讀取時崩潰
CSerialize.cpp:2054
線MUTEX.lock_reading();
Thread 6 (Thread 0x80d4e00 (runnable)):
#0 0x4864f11d in pthread_mutex_lock() from /lib/libpthread.so.2
#1 0x4864b558 in pthread_rwlock_init() from /lib/libpthread.so.2
#2 0x4864b659 in pthread_rwlock_rdlock() from /lib/libpthread.so.2
#3 0x0807ae14 in LocalT::serialize (this=0x80d4e00, [email protected])
at CSerialize.cpp:2054
另外兩個正在運行的線程:
1)插座accept();
2)未來運行的線程在popen()
電話,似乎其執行或管read
。但不知道什麼是__error()
?????
Thread 1 (Thread 0x8614800 (LWP 100343)):
#0 0x4865b8f9 in __error() from /lib/libpthread.so.2
#1 0x4865a15a in pthread_testcancel() from /lib/libpthread.so.2
#2 0x486425bf in read() from /lib/libpthread.so.2
#3 0x08056340 in UT::execute_popen ([email protected],
ptr_output=0xbf2f7d30) at Utils.cpp:75
3)所有其他線程正在睡覺。
我不知道它爲什麼墜毀?也許有人可以承擔一些事情或建議?
== ==編輯
,這裏是一個系統(?)線程(我不會創建它,但計劃總是有+1線程)。它總是:
Thread 8 (Thread 0x80d4a00 (LWP 100051)):
#0 0x4865a79b in pthread_testcancel() from /lib/libpthread.so.2
#1 0x48652412 in pthread_mutexattr_init() from /lib/libpthread.so.2
#2 0x489fd450 in ??()
== EDIT2 - BT的要求==
(gdb) bt
#0 0x4865a7db in pthread_testcancel() from /lib/libpthread.so.2
#1 0x48652412 in pthread_mutexattr_init() from /lib/libpthread.so.2
#2 0x489fd450 in ??()
奇怪......爲什麼??()
?
== EDIT3 - 裝載芯==
Program terminated with signal 11, Segmentation fault.
[skiped]
#0 0x4865a7db in pthread_testcancel() from /lib/libpthread.so.2
[New Thread 0x8614800 (LWP 100343)]
[New Thread 0x8614600 (sleeping)]
[New Thread 0x8614400 (sleeping)]
[New Thread 0x8614200 (sleeping)]
[New Thread 0x8614000 (sleeping)]
[New Thread 0x80d4e00 (runnable)]
[New Thread 0x80d4c00 (sleeping)]
[New Thread 0x80d4a00 (LWP 100051)]
[New Thread 0x80d4000 (runnable)]
[New LWP 100802]
(gdb) info thread
* 10 LWP 100802 0x4865a7db in pthread_testcancel() from /lib/libpthread.so.2
9 Thread 0x80d4000 (runnable) 0x486d7bd3 in accept() from /lib/libc.so.6 -- MAIN() THREAD
8 Thread 0x80d4a00 (LWP 100051) 0x4865a79b in pthread_testcancel()
from /lib/libpthread.so.2 (UNIDENTIFIED THREAD system()?)
7 Thread 0x80d4c00 (sleeping) 0x48651cb6 in pthread_mutexattr_init()
from /lib/libpthread.so.2 (SIGNAL PROCESSOR THREAD)
6 Thread 0x80d4e00 (runnable) 0x4864f11d in pthread_mutex_lock()
from /lib/libpthread.so.2 (MAINTENANCE THREAD)
5 Thread 0x8614000 (sleeping) 0x48651cb6 in pthread_mutexattr_init()
from /lib/libpthread.so.2 (other mutex cond_wait - worker 1)
4 Thread 0x8614200 (sleeping) 0x48651cb6 in pthread_mutexattr_init()
from /lib/libpthread.so.2 (other mutex cond_wait - worker 2)
3 Thread 0x8614400 (sleeping) 0x48651cb6 in pthread_mutexattr_init()
from /lib/libpthread.so.2 (other mutex cond_wait - worker 3)
2 Thread 0x8614600 (sleeping) 0x48651cb6 in pthread_mutexattr_init()
from /lib/libpthread.so.2 (other mutex cond_wait - worker 4)
1 Thread 0x8614800 (LWP 100343) 0x4865b8f9 in __error()
from /lib/libpthread.so.2 (popen() thread see below)
當我創建:1個維護線程(串行化),1個popen()
螺紋,4名工人,1個主,1條信號線= 8個線程.. ..
感謝您的回答。 1)否,主線程處於'accept()'狀態。也許它在sigwait()狀態下的信號線程2)我將嘗試搜索我使用這個互斥鎖的代碼,但是......似乎不是,我總是注意這個...... 3)增加了一些額外的信息。 – abrahab
請''線程',這將顯示你所有的線程 –
如果我上面提到關於不放棄鎖是真的,你會看到一堆線程在等待那個互斥量 –