add concurrency join check for debug pthread_join failed issue
This commit is contained in:
9
deps/oblib/src/lib/thread/thread.cpp
vendored
9
deps/oblib/src/lib/thread/thread.cpp
vendored
@ -56,7 +56,8 @@ Thread::Thread(Runnable runnable, int64_t stack_size)
|
|||||||
stack_addr_(nullptr),
|
stack_addr_(nullptr),
|
||||||
#endif
|
#endif
|
||||||
stack_size_(stack_size),
|
stack_size_(stack_size),
|
||||||
stop_(true)
|
stop_(true),
|
||||||
|
join_concurrency_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Thread::~Thread()
|
Thread::~Thread()
|
||||||
@ -170,6 +171,9 @@ void Thread::wait()
|
|||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
if (pth_ != 0) {
|
if (pth_ != 0) {
|
||||||
|
if (2 <= ATOMIC_AAF(&join_concurrency_, 1)) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
if (OB_FAIL(pthread_join(pth_, nullptr))) {
|
if (OB_FAIL(pthread_join(pth_, nullptr))) {
|
||||||
LOG_ERROR("pthread_join failed", K(ret), K(errno));
|
LOG_ERROR("pthread_join failed", K(ret), K(errno));
|
||||||
#ifndef OB_USE_ASAN
|
#ifndef OB_USE_ASAN
|
||||||
@ -182,6 +186,9 @@ void Thread::wait()
|
|||||||
pid_ = 0;
|
pid_ = 0;
|
||||||
tid_ = 0;
|
tid_ = 0;
|
||||||
runnable_ = nullptr;
|
runnable_ = nullptr;
|
||||||
|
if (1 <= ATOMIC_AAF(&join_concurrency_, -1)) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
deps/oblib/src/lib/thread/thread.h
vendored
1
deps/oblib/src/lib/thread/thread.h
vendored
@ -65,6 +65,7 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
int64_t stack_size_;
|
int64_t stack_size_;
|
||||||
bool stop_;
|
bool stop_;
|
||||||
|
int64_t join_concurrency_;
|
||||||
};
|
};
|
||||||
|
|
||||||
OB_INLINE pid_t Thread::get_pid() const
|
OB_INLINE pid_t Thread::get_pid() const
|
||||||
|
Reference in New Issue
Block a user