I had a mysterious crash in my application, that was not reproducible.
the problem was uncaught SystemException that was caught by the standard terminate handler, which printed e.what() which is useless in Poco Exceptions.
- Code: Select all
terminate called after throwing an instance of 'Poco::SystemException'
what(): System exception
I hacked Exception::what() to print the displayMessage() to stderr, and saw that the message in the SystemException is cannot lock mutex.
I hacked Foundation/include/Poco/Mutex_POSIX.h to cause segmentation fault when it wants to to throw the Exception, in an attempt to get a backtrace of when the problem occurs, the backtrace I got was:
- Code: Select all
Stack trace:
1: 0xb7ec7edb <Poco::ErrorHandler::handle(Poco::Exception const&)+219> (/usr/local/lib/libPocoFoundation.so.6)
2: 0xb7f2bb4a <Poco::PooledThread::run()+2122> (/usr/local/lib/libPocoFoundation.so.6)
3: 0xb7f2583f <Poco::ThreadImpl::runnableEntry(void*)+175> (/usr/local/lib/libPocoFoundation.so.6)
4: 0xb72934c0 <(null)+3072931008> (/lib/i686/cmov/libpthread.so.0)
End of stack trace
I looked at Poco::ErrorHandler::handle(Poco::Exception const&), and saw that it's using a static lock.
- Code: Select all
void ErrorHandler::handle(const Exception& exc)
{
FastMutex::ScopedLock lock(_mutex);
try
{
_pHandler->exception(exc);
}
catch (...)
{
}
}
the problem is probably that while the application is exiting, that static lock is destroyed and the locking fails.
this cause the actual exception to be lost, and really makes things hard to debug.
I commented out the locking, and this caused my problem to disappear (so I am not sure if I actually have an uncaught exception in one of my threads.
I am using poco-1.3.3p1.
what do you guys think?





