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  2011  2012  <20132014  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  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Thread Handle Leak: EPICS Base on Windows
From: <[email protected]>
To: <[email protected]>
Date: Wed, 1 May 2013 10:13:32 +0000
There appears to be a minor resource leak in EPICS base when running on Windows.

This was tested on Windows Server 2008 R2 SP1 and EPICS R3.14.12.3 however I believe it will effect all Windows versions and earlier versions of EPICS.

To reproduce this issue:

  *   Create a basic IOC with a single PV
  *   start the IOC and monitor the process using Sysinternals process explorer http://technet.microsoft.com/en-us/sysinternals/bb896653
  *   do a caget on the PV
  *   watch the thread handles increase by 2 for each caget

I only expect this to cause a problem for very long running IOCs.

The change below stopped this resource leak:-

Regards,
   giles...

Index: src/libCom/osi/os/WIN32/osdThread.c
===================================================================
--- src/libCom/osi/os/WIN32/osdThread.c (revision 89701)
+++ src/libCom/osi/os/WIN32/osdThread.c (working copy)
@@ -7,7 +7,7 @@
 * and higher are distributed subject to a Software License Agreement found
 * in file LICENSE that is included with this distribution.
 \*************************************************************************/
-
+
 /*
  * Revision-Id: [email protected]
  *
@@ -247,9 +247,8 @@
         LeaveCriticalSection ( & pGbl->mutex );

         /* close the handle if its an implicit thread id */
-        if ( ! pParm->funptr ) {
-            CloseHandle ( pParm->handle );
-        }
+        /* GK 04/2013 - in fact all threads opened with _beginthreadex need their handle closed */
+        CloseHandle ( pParm->handle );
         free ( pParm );
         TlsSetValue ( pGbl->tlsIndexThreadLibraryEPICS, 0 );
     }


-- 
This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd. 
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom
 





Replies:
Re: Thread Handle Leak: EPICS Base on Windows Andrew Johnson

Navigate by Date:
Prev: Re: vishnu chaudhari
Next: Change in behavior of the fullPathName.pl Scott Higgins
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Would like to add regular expressions to dbpr Benjamin Franksen
Next: Re: Thread Handle Leak: EPICS Base on Windows Andrew Johnson
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 20 Apr 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·