Reputation: 53257
I guess this is a really nasty issue - seems like one of the property destructors of my class creates deadlock. Property destructors are called automatically after class destructor. And I'd like to call them manually and make a log entry after every single one succeeds.
The problem only occurs on devices, where debugger can't be used, so I am using log instead.
Client::~Client() {
// Stops io service and disconnects sockets
exit();
LOG("io_service stopped"<<endl);
// Destroy IO service
io_.~io_service();
LOG("io_service destroyed"<<endl);
}
But the code above actually causes exception, because the ~io_service()
gets called twice.
So is there a way to do this properly? If not, what's an alternative to debugging destructors?
Upvotes: 0
Views: 998
Reputation: 26506
You can't alter the compiler behaviour like that. the compiler will augment the destructor to destruct nested objects.
What you can do is to declare io
as a pointer and allocate it dynamically with new
. then call delete io
and monitor what happens there.
Other solution is just to put a breakpoint on the io
destructor and follow what happens there upon destruction. this is probably the best idea.
Upvotes: 1