0

I am using boost threads, upon calling notify_all() within the destructor i am seeing a segmentation fault. Here is the stack:

(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 ()
godzilla
  • 3,005
  • 7
  • 44
  • 60

1 Answers1

2

Without actually seeing the code, this is mostly conjecture.

From your debug:

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

It's saying that this (inside the condition variable) is nullptr. It appears that you are calling cv->notify_all() where cv is nullptr (aka 0). Is it possible you are deleting the condition variable prior to trying to use it?

Yakk - Adam Nevraumont
  • 262,606
  • 27
  • 330
  • 524
Dave S
  • 20,507
  • 3
  • 48
  • 68
  • You meant to say `nullptr` or `0x0` and not `NULL`, right? :) –  Apr 23 '13 at 13:56
  • @Vlad: You're corredt. Edited. – Dave S Apr 23 '13 at 13:57
  • this is the troubling part, i am not deleting this variable anywhere,m_flushCond = std::unique_ptr(new boost::condition_variable()); – godzilla Apr 23 '13 at 14:18
  • @godzilla: Well, a unique_ptr can be reset or moved from, both of which reset its value to nullptr. I would start by figuring out when that occurs. – Dave S Apr 23 '13 at 14:25
  • this only occurs when i call the destructor, it seems as though no mutex is able to be created when calling the destructor. I will look into why this is – godzilla Apr 23 '13 at 14:32
  • really strange, i perform all the operations outside of the destructor and it works find, i call the same function within a destructor and i get a crash, oh well this will do for now. It would be nice to know why it would make any difference if this call was being made from a destructor would make any difference, cheers guys – godzilla Apr 23 '13 at 15:02
  • @godzilla I have the SAME problem. Did you find any solutions for that? – TonySalimi Mar 01 '19 at 14:37