CA fails on big-endian host

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

Bug Description

From Yevgeny A. Gusev,

     ca_array_put_callback() doesn't work correctly if IOC is located in PPC-based controller. The problem is in caNetConvert() routine from base-3.14.9/src/ca/convert.cpp which is called by write_notify_action() (and by other routines) from base-3.14.9/src/rsrv/camessage.c.

base-3.14.9/src/ca/convert.cpp:

int caNetConvert ( unsigned type, const void *pSrc, void *pDest,
                    int hton, arrayElementCount count ) {
# ifdef EPICS_CONVERSION_REQUIRED
         if ( type >= NELEMENTS ( cac_dbr_cvrt ) ) {
             return ECA_BADTYPE;
         }
         ( * cac_dbr_cvrt [ type ] ) ( pSrc, pDest, hton, count );
# else
         if ( INVALID_DB_REQ ( type ) ) {
             return ECA_BADTYPE;
         }
         if ( pSrc != pDest ) {
             memcpy ( pDest, pSrc, count );
         }
# endif
     return ECA_NORMAL;
}

     The third argument in memcpy() must be not count but dbr_size_n( type, count ) - size in bytes, so instead of

     memcpy( pDest, pSrc, count )

must be

     memcpy( pDest, pSrc, dbr_size_n( type, count ) ).

     Please check also cvrt_gr_char(), cvrt_ctrl_char(), cvrt_sts_char() and cvrt_time_char() routines from ca/convert.cpp where num (number of
values) is used in memcpy() calls.

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

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

I committed this patch

cvs diff -r 1.11.2.4 -r 1.11.2.5 -u -wb -i -- convert.cpp convert.cpp
Index: convert.cpp
===================================================================
RCS file: /net/phoebus/epicsmgr/cvsroot/epics/base/src/ca/convert.cpp,v
retrieving revision 1.11.2.4
retrieving revision 1.11.2.5
diff -c -b -u -w -b -i -r1.11.2.4 -r1.11.2.5
cvs diff: conflicting specifications of output style
--- convert.cpp 18 Nov 2006 00:39:50 -0000 1.11.2.4
+++ convert.cpp 29 Mar 2007 16:31:38 -0000 1.11.2.5
@@ -1431,7 +1431,7 @@
             return ECA_BADTYPE;
         }
         if ( pSrc != pDest ) {
- memcpy ( pDest, pSrc, count );
+ memcpy ( pDest, pSrc, dbr_size_n ( type, count ) );
         }
 # endif
     return ECA_NORMAL;

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

fixed in R3.14.10 (or in R3.14.9.1)

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.