Comment 2 for bug 697516

Revision history for this message
Alex Chen (alex-chen) wrote : Re: [Bug 697516] Re: Crash occurs in Com.dll if filetime is before the EPICS epoch

Jeff,

Yes, the exception (overflow in nanosecond field) is caught in EPICS Base
3.14.12, but the root cause of the exception is not resolved. I've checked
the code at line 486 of base-3.14.12\src\libCom\osi\os\WIN32\osdTime.cpp,
there is still possible negative epicsTimeFromCurrentFileTime if system
returns a filetime before the EPICS Epoch. During such situations, we may
consider how to adjust the 'perfCounterFreq' which is currently
implemented by line 489 to 520 in file
base-3.14.12\src\libCom\osi\os\WIN32\osdTime.cpp.

Thanks,

Alex

From:
Jeff Hill <email address hidden>
To:
<email address hidden>
Date:
01/07/2011 12:26 AM
Subject:
[Bug 697516] Re: Crash occurs in Com.dll if filetime is before the EPICS
epoch
Sent by:
<email address hidden>

maybe this is fixed in recent EPICS. I see code like this which seems to
handle that exception?

void epicsThread :: printLastChanceExceptionMessage (
    const char * pExceptionTypeName,
    const char * pExceptionContext )
{
    char date[64];
    try {
        epicsTime cur = epicsTime :: getCurrent ();
        cur.strftime ( date, sizeof ( date ), "%a %b %d %Y %H:%M:%S.%f");
    }
    catch ( ... ) {
        strcpy ( date, "<UKN DATE>" );
    }
    char name [128];
    epicsThreadGetName ( this->id, name, sizeof ( name ) );
    errlogPrintf (
        "epicsThread: Unexpected C++ exception \"%s\" "
        "with type \"%s\" in thread \"%s\" at %s\n",
        pExceptionContext, pExceptionTypeName, name, date );
    errlogFlush ();
    // this should behave as the C++ implementation intends when an
    // exception isnt handled. If users dont like this behavior, they
    // can install an application specific unexpected handler.
    std::unexpected ();
}

--
You received this bug notification because you are a direct subscriber
of the bug.
https://bugs.launchpad.net/bugs/697516

Title:
  Crash occurs in Com.dll if filetime is before the EPICS epoch

Status in EPICS Base:
  New

Bug description:
  EPICS Base 3.14.9

File: \src\libCom\osi\epicsThread.cpp

Function: extern "C" void epicsThreadCallEntryPoint ( void * pPvt )

Problem:
If system returns a filetime before the EPICS epoch, exception
std::logic_error is thrown from the 'catch' (at line 67 'catch (
std::exception & except )' and at line 83 ' catch ( ... )'). The
std::logic_error is actually thrown by the 'epicsTime cur =
epicsTime::getCurrent ();' complaining that epicsTimeStamp has overflow in
nanosecond field.

The root cause:
File: \src\libCom\osi\os\WIN32\osdTime.cpp
Function: epicsTimerNotify::expireStatus currentTime::expire ( const
epicsTime & )
Line 516:
‘LONGLONG epicsTimeFromCurrentFileTime =
        ( curFileTime.QuadPart - epicsEpochInFileTime ) *
        ET_TICKS_PER_FT_TICK;’
curFileTime could be smaller than the EPICS epoch if user changes the
system time, so this will produce a wield 'epicsTimeFromCurrentFileTime'
and we will assign its value to this->epicsTimeLast' at line 526
'this->epicsTimeLast = epicsTimeFromCurrentFileTime;'

We need to handle:
If the filetime returned by system is earlier than the EPICS epoch, how do
we generate the 'delta' (at line 520) and adjust the perfCounterFreq
accordingly.

To unsubscribe from this bug, go to:
https://bugs.launchpad.net/epics-base/+bug/697516/+subscribe