클래스 LocalT
에는 read-write-mutex
을 실현 한 다른 클래스의 멤버가 있습니다. 뮤텍스는 생성자에서 초기화되고 잠금을 읽기 위해 pthread_rwlock_rdlock(&aMutex);
을 사용합니다. 그래서, 뮤텍스 클래스를 가진 모든 괜찮아 보인다. 그러나 일부는 LocalT
객체가 그의 뮤텍스 멤버를 읽기 위해 잠글 때 프로그램이 다운되었습니다.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) 다른 모든 스레드는 자고 있습니다.
나는 추락 한 이유가 무엇입니까? 누군가 뭔가를 취하거나 제안 할 수 있을까요?
== 편집 == 여기
와 하나 개의 시스템 (?) 스레드 (내가 그것을 생성하지 않지만, 프로그램은 항상 하나의 스레드를 가지고)입니다. 항상 :
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 -
(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 ??()
이상하게 ... 왜 ??()
==의 요청에 따라 BT?
== 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)
로드 I 만든 (직렬화) 1 유지 실 1 개 popen()
스레드 4 명 노동자, 1 개 주, 1 개 신호 스레드 = 8 개 스레드 .. ..
답변 해 주셔서 감사합니다. 1) no,'accept()'상태의 주 스레드. 어쩌면'sigwait()'상태의 시그널 스레드 2) 내가이 뮤텍스를 사용하는 곳에서 코드를 검색하려고 노력할 것이지만 ... 그렇지 않다, 나는 항상 그것에주의를 기울인다. 3) 추가 된 약간의 정보. – abrahab
pls는 거기에있는 모든 스레드를 보여줄'info threads'를 수행합니다. –
만약 내가 위의 lock을 포기하지 않는 것에 대해 언급 한 것이 사실이라면 mutex에서 기다리는 스레드들을 볼 수 있습니다 –