Add-Ons & Services

Bug in ErrorHandler

Please post support and help requests here.
Posts: 4
Joined: 24 Dec 2008, 10:05

Bug in ErrorHandler

Postby omry » 19 Nov 2009, 20:23

Hi All,
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);
    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?

Posts: 4
Joined: 24 Dec 2008, 10:05

Re: Bug in ErrorHandler

Postby omry » 11 Jan 2010, 15:18


Posts: 1183
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Bug in ErrorHandler

Postby guenter » 15 Jan 2010, 11:00

I'm a bit reluctant to remove the mutex here, as it's there for a reason.
I'd say that if you have some threads still executing while your applications is exiting and statics are being destroyed, you'll have some serious issues with your application.

Return to “Support”

Who is online

Users browsing this forum: No registered users and 3 guests