EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Bugs in StreamDevice 2
From: Ralph Lange <[email protected]>
To: Dirk Zimoch <[email protected]>
Cc: EPICS Tech Talk <[email protected]>
Date: Fri, 09 Sep 2011 18:06:00 +0200
Hi Dirk,

I discovered two bugs in current StreamDevice.

1. (trivial): StreamBuffer uses the wrong operator delete for arrays.
2. (major): On 64bit archs, the waveform device support corrupts IOC
memory when the record's FTVL is LONG or ULONG, leading to IOC crashes
(segfaults).

Patches are enclosed, the IOC is running happily ever after.

Cheers,
~Ralph

diff -u -r orig//streamDevice/src/StreamBuffer.cc 2-4-1//streamDevice/src/StreamBuffer.cc
--- orig//streamDevice/src/StreamBuffer.cc	2010-04-08 23:32:44.000000000 +0200
+++ 2-4-1//streamDevice/src/StreamBuffer.cc	2011-09-09 17:02:16.000000000 +0200
@@ -102,7 +102,7 @@
     memset(newbuffer+len, 0, newcap-len);
     if (buffer != local)
     {
-        delete buffer;
+        delete [] buffer;
     }
     buffer = newbuffer;
     cap = newcap;
@@ -212,7 +212,7 @@
         memset(newbuffer+newlen, 0, newcap-newlen);
         if (buffer != local)
         {
-            delete buffer;
+            delete [] buffer;
         }
         buffer = newbuffer;
         cap = newcap;
diff -u -r orig//streamDevice/src/StreamBuffer.h 2-4-1//streamDevice/src/StreamBuffer.h
--- orig//streamDevice/src/StreamBuffer.h	2010-04-08 23:32:44.000000000 +0200
+++ 2-4-1//streamDevice/src/StreamBuffer.h	2011-09-09 17:00:22.000000000 +0200
@@ -64,7 +64,7 @@
         {init(NULL, size);}
 
     ~StreamBuffer()
-        {if (buffer != local) delete buffer;}
+        {if (buffer != local) delete [] buffer;}
 
     // operator (): get char* pointing to index
     const char* operator()(long index=0) const
diff -u -r orig//streamDevice/src/devwaveformStream.c 2-4-1//streamDevice/src/devwaveformStream.c
--- orig//streamDevice/src/devwaveformStream.c	2010-04-08 23:32:44.000000000 +0200
+++ 2-4-1//streamDevice/src/devwaveformStream.c	2011-09-09 17:16:45.000000000 +0200
@@ -74,7 +74,7 @@
                         break;
                     case DBF_LONG:
                     case DBF_ULONG:
-                        ((long *)wf->bptr)[wf->nord] = lval;
+                        ((epicsInt32 *)wf->bptr)[wf->nord] = lval;
                         break;
                     case DBF_SHORT:
                     case DBF_USHORT:

Replies:
Re: Bugs in StreamDevice 2 Dirk Zimoch

Navigate by Date:
Prev: RE: Need std 2.9 to build mca Mark Rivers
Next: Another newbie question - seq record example? Paul Nord
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: Need std 2.9 to build mca Mark Rivers
Next: Re: Bugs in StreamDevice 2 Dirk Zimoch
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·