IOCs on 64-bit archs report nsec=0 timestamps

Bug #541339 reported by Andrew Johnson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
EPICS Base
Fix Released
High
Andrew Johnson

Bug Description

Using camonitor or caget -a (on any platform) to get a value with timestamp from an IOC that is running on a 64-bit platform always returns zero in the nsec field of the timestamp. Within the IOC though timestamps work properly, showing fractional seconds in the output from dbpr.

Found on linux-x86_64, confirmed on solaris-x86_64, IOC segfaulted elsewhere on solaris-sparc64.

Steps to reproduce:
Use makeBaseApp.pl to create and run an instance of the example template with a 64-bit architecture.

Run camonitor or 'caget -a' against one of the records in the IOC and examine the displayed timestamps.

Additional information:
Timestamp handling on 64-bit IOCs works proplerly using dbAccess; it's only when CA is involved that the problem appears. Proof: Using the example application, set a record's TSEL field to point to the TIME field of another record in the IOC and the TIME field will be updated from the other record as normal. Add the CA flag to that same link and the record's timestamp will have its fractional seconds truncated (display the record's timestamps on the IOC using dbpr to show this).

Platform: 64-bit

Version: R3.14.9

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

Tags: ca 3.14 3.14.9
Revision history for this message
Andrew Johnson (anj) wrote :

Found code in src/db/dbAccess.c getOptions() which was using an unsigned long * to copy the timestamp from the record's TIME field. Changed that to use an epicsUInt32 * as follows and the problem goes away:

Index: dbAccess.c
===================================================================
RCS file: /net/phoebus/epicsmgr/cvsroot/epics/base/src/db/dbAccess.c,v
retrieving revision 1.116.2.11
diff -u -b -r1.116.2.11 dbAccess.c
--- dbAccess.c 19 Dec 2006 16:20:47 -0000 1.116.2.11
+++ dbAccess.c 21 Feb 2008 19:46:00 -0000
@@ -354,15 +354,15 @@
            pbuffer += dbr_precision_size;
        }
        if( (*options) & DBR_TIME ) {
- unsigned long *pulong = (unsigned long *)pbuffer;
+ epicsUInt32 *ptime = (epicsUInt32 *)pbuffer;
            if(pfl!=NULL) {
- *pulong++ = pfl->time.secPastEpoch;
- *pulong++ = pfl->time.nsec;
+ *ptime++ = pfl->time.secPastEpoch;
+ *ptime++ = pfl->time.nsec;
            } else {
- *pulong++ = pcommon->time.secPastEpoch;
- *pulong++ = pcommon->time.nsec;
+ *ptime++ = pcommon->time.secPastEpoch;
+ *ptime++ = pcommon->time.nsec;
            }
- pbuffer = (char *)pulong;
+ pbuffer = (char *)ptime;
        }
        if( (*options) & DBR_ENUM_STRS )
            get_enum_strs(paddr, &pbuffer, prset, options);

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

Fixed in R3.14.10.

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

R3.14.10 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.