0

我正在使用 boost 线程,在析构函数中调用 notify_all() 时,我看到了分段错误。这是堆栈:

(gdb) where
#0  0x00007ffff752de84 in pthread_mutex_lock ()
   from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00007fffe85ab22e in        boost::pthread::pthread_mutex_scoped_lock::pthread_mutex_scoped_lock (this=0x7fffffffdba0, m_=0x0)
    at /usr/include/boost/thread/pthread/pthread_mutex_scoped_lock.hpp:26
#2  0x00007fffe85abb5d in boost::condition_variable::notify_one (this=0x0)
    at /usr/include/boost/thread/pthread/condition_variable.hpp:88
#3  0x00007fffe8690864 in CampaignFrequency::stopFlushThread (this=0x6ad590)
    at /home/git/gitRTB/infinityplus/src/common/shm/CampaignFrequency.cpp:197
#4  0x00007fffe868ffd7 in CampaignFrequency::~CampaignFrequency (
    this=0x6ad590, __in_chrg=<optimised out>)
    at /home/git/gitRTB/infinityplus/src/common/shm/CampaignFrequency.cpp:81
#5  0x00007fffe85bdc37 in rtb_child_init (s=0x7ffff7fc3238)
    at /home/git/gitRTB/infinityplus/src/bidder/mod_rtb.cpp:265
#6  0x000000000044784c in ap_run_child_init ()
#7  0x000000000042817c in ?? ()
#8  0x0000000000463594 in ?? ()
#9  0x00000000004635f4 in ?? ()
#10 0x00000000004643fd in ?? ()
#11 0x000000000042f026 in ap_run_mpm ()
#12 0x0000000000428d74 in main ()
4

1 回答 1

2

在没有实际看到代码的情况下,这主要是推测。

从您的调试中:

#2  0x00007fffe85abb5d in boost::condition_variable::notify_one (this=0x0)
    at /usr/include/boost/thread/pthread/condition_variable.hpp:88

就是说 this(在条件变量中)是nullptr. 看来您正在调用cv->notify_all()cv 所在的位置nullptr(又名0)。您是否有可能在尝试使用条件变量之前删除它?

于 2013-04-23T13:54:02.403 回答