Experimental Physics and
| |||||||||||||||
|
I experienced crashes of EDM related to the use of the XY-graph widget on the Linux x86_64 platform. Crashes of EDM on 64-bit systems have been reported earlier on this mailing list: http://www.aps.anl.gov/epics/tech-talk/2010/msg00915.php http://www.aps.anl.gov/epics/tech-talk/2010/msg00227.php I think that I now found the origin of these crashes: The code in xygraph.cc makes assumptions about the size of the int and long datatypes. In particular it assumes that both int and long are 32 bit. While this is true for 32-bit systems, on 64-bit systems long is 64-bit. Because of these assumptions, the sub-arrays in the yPvData array are allocated to small and other data is overwritten when these arrays are accessed as arrays of longs. I attached a patch for EDM 1.12.39 which should fix this problem. Instead of using hard-coded sizes for different data types, it uses the sizeof operator in order to determine how much memory needs to be allocated. I could not find an e-mail address for the EDM maintainer in the EDM sources. Thus, I hope that someone from the EDM maintainers is reading this mailing-list, so that this patch can be included in future EDM releases. Until then, I hope this patch might be useful for other people experiencing the same problem. - Sebastian diff -Naur edm-1.12.39.orig/baselib/xygraph.cc edm-1.12.39/baselib/xygraph.cc --- edm-1.12.39.orig/baselib/xygraph.cc 2010-10-27 16:02:15.000000000 +0200 +++ edm-1.12.39/baselib/xygraph.cc 2010-12-17 21:35:56.000000000 +0100 @@ -9025,25 +9025,29 @@ // specificType switch ( yPvType[i] ) { case ProcessVariable::specificType::flt: - eleSize = 4; + eleSize = sizeof(float); break; case ProcessVariable::specificType::real: - eleSize = 8; + eleSize = sizeof(double); break; case ProcessVariable::specificType::shrt: - eleSize = 2; + eleSize = sizeof(short); break; case ProcessVariable::specificType::chr: - eleSize = 1; + eleSize = sizeof(char); break; case ProcessVariable::specificType::integer: - eleSize = 4; + // At some places in the code, integers are assumed to + // be longs. As on some platforms (64-bit) long has + // 8 bytes and int has only 4 bytes, we assume the + // longer one here to be save. + eleSize = sizeof(long); break; case ProcessVariable::specificType::enumerated: - eleSize = 2; + eleSize = sizeof(short); break; default: - eleSize = 8; + eleSize = sizeof(double); break; } @@ -9080,25 +9084,29 @@ // specificType switch ( xPvType[i] ) { case ProcessVariable::specificType::flt: - eleSize = 4; + eleSize = sizeof(float); break; case ProcessVariable::specificType::real: - eleSize = 8; + eleSize = sizeof(double); break; case ProcessVariable::specificType::shrt: - eleSize = 2; + eleSize = sizeof(short); break; case ProcessVariable::specificType::chr: - eleSize = 1; + eleSize = sizeof(char); break; case ProcessVariable::specificType::integer: - eleSize = 4; + // At some places in the code, integers are assumed to + // be longs. As on some platforms (64-bit) long has + // 8 bytes and int has only 4 bytes, we assume the + // longer one here to be save. + eleSize = sizeof(long); break; case ProcessVariable::specificType::enumerated: - eleSize = 2; + eleSize = sizeof(short); break; default: - eleSize = 8; + eleSize = sizeof(double); break; }
| ||||||||||||||
ANJ, 19 Dec 2010 |
·
Home
·
News
·
About
·
Base
·
Modules
·
Extensions
·
Distributions
·
Download
·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing · |