MantisBT - JANA
View Issue Details
0000287JANAFeature Requestpublic2012-09-24 07:052012-09-24 07:48
davidl 
davidl 
normalminoralways
resolvedfixed 
0000287: Add catch for std::exception to JFactory::Get
This comes from Paul. Here is the original e-mail:

In JFactory<T>::Get(vector<const T*> &d), could you please add catch statements for "std" exceptions (and set the busy flag to zero there too!). If nothing else it helps me track down where std::bad_alloc is thrown from by looking at the factory call stack.

Also, and this may be a bad idea, but maybe if the framework could call JApplication::RootUnLock() (and any other unlocks) when an exception was thrown, it would help trying to recover from them.
No tags attached.
Issue History
2012-09-24 07:05davidlNew Issue
2012-09-24 07:45davidlNote Added: 0000441
2012-09-24 07:45davidlStatusnew => resolved
2012-09-24 07:45davidlResolutionopen => fixed
2012-09-24 07:45davidlAssigned To => davidl
2012-09-24 07:48davidlNote Added: 0000442

Notes
(0000441)
davidl   
2012-09-24 07:45   
Modified the catch statements in JFactory.h to catch std::exception instead. Since JException inherits from std::exception, it will be caught as well.

Committed in revision 1053. This will appear in JANA 0.6.6
(0000442)
davidl   
2012-09-24 07:48   
We cannot unlock all mutexes in the catch block because we don't know if they are locked or who holds them and most importantly, if they will be unlocked after we return. Unlocking a mutex you do not own is "undefined" according to the pthreads documentation. Unlocking twice and unlocking an un-locked or un-owned mutex would all lead to undefined behavior.