IOCs on 64-bit archs report nsec=0 timestamps
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://
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 ======= ======= ======= ======= ======= ======= ======= ======= ==== epicsmgr/ cvsroot/ epics/base/ src/db/ dbAccess. c,v
if( pfl!=NULL) { secPastEpoch; secPastEpoch; >time.secPastEp och; >time.secPastEp och;
get_ enum_strs( paddr, &pbuffer, prset, options);
=======
RCS file: /net/phoebus/
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;
- *pulong++ = pfl->time.
- *pulong++ = pfl->time.nsec;
+ *ptime++ = pfl->time.
+ *ptime++ = pfl->time.nsec;
} else {
- *pulong++ = pcommon-
- *pulong++ = pcommon->time.nsec;
+ *ptime++ = pcommon-
+ *ptime++ = pcommon->time.nsec;
}
- pbuffer = (char *)pulong;
+ pbuffer = (char *)ptime;
}
if( (*options) & DBR_ENUM_STRS )