[Threads] join_all() strange behavior?
Hi,
I have a strange problem. The destructor of a class calls join_all().
But it seems that he hangs there. Even though some other code behind the
join_all() is executed before it finishs!
Lets get concret:
seal::~seal()
{
ThgPrgs.join_all();
cout<<"Crabd quits, goodbye"< ::accept_handler The class seal holds some other classes in shared_ptrs which are will be
destroyed in this moment too. Some of them have also a join_all() in their
destructors. Im wondering if they produce the lock?
But the main question here is:
I read "Crabd quits, goodbye" and after this i stop the program and i get in
the backtrace from gdb the line "#4 0x0808742c in ~seal (this=0x80c9890)
at src/seal.cpp:20". And Line 20 in seal.cpp is the line with join_all().
How is this possible, though join_all should block?
Thanks for your help and for reading this.
Manuel Jung, Germany
Manuel Jung wrote:
Hi,
I have a strange problem. The destructor of a class calls join_all(). But it seems that he hangs there. Even though some other code behind the join_all() is executed before it finishs! Lets get concret:
seal::~seal() { ThgPrgs.join_all(); cout<<"Crabd quits, goodbye"<
When i run my program, the last message is "Crabd quits, goodbye" and it should exit then, but it doesnt. If i stop it running in gdb an do a backtrace i get the following:
[...] You have two calls to ~seal in the call stack. It's quite possible that a third ~seal has finished and produced the message, after which the second ~seal has deadlocked in join_all for some reason. You could try a cout<<"~seal: joining all" before the join_all call to see how many times it will occur.
participants (2)
-
Manuel Jung
-
Peter Dimov