timer queue should have try / catch block around call to user's expiration callback

Bug #541364 reported by Jeff Hill
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
EPICS Base
Fix Released
Wishlist
Jeff Hill

Bug Description

if an exception occurs in the user's expiration callback
the library should catch it and print a diagnostic message,
the timer queue thread should continue to run, and the
timer queue thread should not be compromised by an
exception occurring in, and not caught by, user code

Original Mantis Bug: mantis-336
    http://www.aps.anl.gov/epics/mantis/view_bug_page.php?f_id=336

Tags: libcom 3.14
Revision history for this message
Jeff Hill (johill-lanl) wrote :
Download full text (4.2 KiB)

I committed this patch

cvs diff -r R3-14-2_branch:yesterday -wb (in directory C:\hill\R3.14.dll_hell_fix\epics\base\src\libCom\timer\)
Index: timerPrivate.h
===================================================================
RCS file: /net/phoebus/epicsmgr/cvsroot/epics/base/src/libCom/timer/timerPrivate.h,v
retrieving revision 1.30.2.5
retrieving revision 1.30.2.6
diff -u -b -w -b -r1.30.2.5 -r1.30.2.6
--- timerPrivate.h 23 Feb 2009 22:51:50 -0000 1.30.2.5
+++ timerPrivate.h 13 Mar 2009 17:23:06 -0000 1.30.2.6
@@ -8,7 +8,7 @@
 * in file LICENSE that is included with this distribution.
 \*************************************************************************/
 /*
- * $Id: timerPrivate.h,v 1.30.2.5 2009/02/23 22:51:50 anj Exp $
+ * $Id: timerPrivate.h,v 1.30.2.6 2009/03/13 17:23:06 jhill Exp $
  *
  * Author Jeffrey O. Hill
  * <email address hidden>
@@ -18,6 +18,8 @@
 #ifndef epicsTimerPrivate_h
 #define epicsTimerPrivate_h

+#include <typeinfo>
+
 #include "tsFreeList.h"
 #include "epicsSingleton.h"
 #include "tsDLList.h"
@@ -86,6 +88,8 @@
     friend class timerQueue;
 };

+using std :: type_info;
+
 class timerQueue : public epicsTimerQueue {
 public:
     timerQueue ( epicsTimerQueueNotify &notify );
@@ -103,7 +107,11 @@
     epicsTimerQueueNotify & notify;
     timer * pExpireTmr;
     epicsThreadId processThread;
+ epicsTime exceptMsgTimeStamp;
     bool cancelPending;
+ static const double exceptMsgMinPeriod;
+ void printExceptMsg ( const char * pName,
+ const type_info & type );
  timerQueue ( const timerQueue & );
     timerQueue & operator = ( const timerQueue & );
     friend class timer;
Index: timerQueue.cpp
===================================================================
RCS file: /net/phoebus/epicsmgr/cvsroot/epics/base/src/libCom/timer/timerQueue.cpp,v
retrieving revision 1.22.2.1
retrieving revision 1.22.2.2
diff -u -b -w -b -r1.22.2.1 -r1.22.2.2
--- timerQueue.cpp 8 Oct 2004 15:12:19 -0000 1.22.2.1
+++ timerQueue.cpp 13 Mar 2009 17:23:07 -0000 1.22.2.2
@@ -19,12 +19,19 @@
 #define epicsExportSharedSymbols
 #include "epicsGuard.h"
 #include "timerPrivate.h"
+#include "errlog.h"
+
+const double timerQueue :: exceptMsgMinPeriod = 60.0 * 5.0; // seconds

 epicsTimerQueue::~epicsTimerQueue () {}

 timerQueue::timerQueue ( epicsTimerQueueNotify & notifyIn ) :
- notify ( notifyIn ), pExpireTmr ( 0 ),
- processThread ( 0 ), cancelPending ( false )
+ notify ( notifyIn ),
+ pExpireTmr ( 0 ),
+ processThread ( 0 ),
+ exceptMsgTimeStamp (
+ epicsTime :: getCurrent () - exceptMsgMinPeriod ),
+ cancelPending ( false )
 {
 }

@@ -36,6 +43,30 @@
     }
 }

+void timerQueue ::
+ printExceptMsg ( const char * pName, const type_info & type )
+{
+ epicsTime cur = epicsTime :: getCurrent ();
+ double delay = cur - this->exceptMsgTimeStamp;
+ if ( delay >= exceptMsgMinPeriod ) {
+ this->exceptMsgTimeStamp = cur;
+ char date[64];
+ cur.strftime ( date, sizeof ( date ),
+ "%a %b %d %Y %H:%M:%S.%f" );
+ // we dont touch the typeid for the timer expiration
+ // notify interface here beca...

Read more...

Revision history for this message
Jeff Hill (johill-lanl) wrote :

fixed in r3.14.11

Revision history for this message
Andrew Johnson (anj) wrote :

R3.14.11 released.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.