EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: [Bug 541239] Re: explicitly unloading Com.dll causes crash
From: Andrew Johnson via Core-talk <[email protected]>
To: [email protected]
Date: Tue, 15 Oct 2019 15:46:18 -0000
If there are any epicsThreads (such as the errlog thread) that have not
been shut down before you unload the library they will probably cause a
crash. We don't currently have a 'stop all threads' API that could be
called to shut everything down without exiting, but it's something that
could be provided for the libCom and CA subsystems at least, and recent
changes on the EPICS 7 branch might make this easier.

Comment here or email the EPICS core-talk list with any offers of help
to develop this...

-- 
You received this bug notification because you are a member of EPICS
Core Developers, which is subscribed to EPICS Base.
Matching subscriptions: epics-core-list-subscription
https://bugs.launchpad.net/bugs/541239

Title:
  explicitly unloading Com.dll causes crash

Status in EPICS Base:
  Fix Released

Bug description:
  From Liyu Andrei:

  	I met problem with CA again. If I did the simplest program in
  Visual C++ 
  ==============
  	iStatus = ca_context_create( ca_enable_preemptive_callback);
  	ca_context_destroy();
  ==============
  I don't see any message.

  	If I do dll with function that has empty body and call it from
  LabView I haven't problem too. Couple sentence about it if you haven't
  experience with LabView. At first, there LabView has next steps 
  	- start LabView
  	- loads VI (LabView program)
  	- VI starts - stops
  	- unload VI 
  	- stop LabView 

  	Then If I add these couple lines in function body
  - LabView program (VI) continues to work. I can run a lot of times.
  - if I close (unload) LabView program (VI) LabView craches with next
  message
  =============
  Unhandled exception in LabView.exe:0xC0000005:Access Violation
  =============
  I see this message because I work under Visual C++. I don't see anything
  in normal usage (without VC).

  Now I work with Epics 3.14.4.
  Maybe you have any suggestion?

  
  Additional information:

  A program reproducing this issue....

  
  // linkTest.cpp : Defines the entry point for the console application.
  //

  #include "stdio.h"

  #include "windows.h"

  #include "cadef.h"

  typedef int ( epicsShareAPI * p_ca_context_create) 
      ( enum ca_preemptive_callback_select );

  typedef void ( epicsShareAPI * p_ca_context_destroy )
      ( void );

  typedef int ( epicsShareAPI * p_ca_create_channel )
  (
       const char     *pChanName, 
       caCh           *pConnStateCallback, 
       void           *pUserPrivate,
       capri          priority,
       chid           *pChanID
  );

  typedef int ( epicsShareAPI * p_ca_clear_channel )
  (
       chid
  );

  typedef int ( epicsShareAPI * p_ca_pend_io )
      ( ca_real timeOut );

  void MYSEVCHK (int CA_ERROR_CODE, const char * MESSAGE_STRING) 
  { 
      if(!(CA_ERROR_CODE & CA_M_SUCCESS)) {
          fprintf ( stderr, "exiting because CA status was %d context was "%s"\n",
              CA_ERROR_CODE, 
              MESSAGE_STRING ); 
          SuspendThread ( GetCurrentThread () );
      }
  }

  #define myassert(EXP) ((EXP)?(void)1:_myassert(#EXP))

  void _myassert ( const char * pStr ) 
  {
      fprintf ( stderr, 
          "assert fail "%s"\n", pStr ), 
      SuspendThread ( GetCurrentThread () );
  }

  int main ( int argc, char ** argv[] )
  {
      for ( unsigned i = 0; i < 1000; i++ ) {
          HINSTANCE hLibrary = LoadLibrary("ca");
          myassert ( hLibrary );
       
          p_ca_context_create pF_ca_context_create = ( p_ca_context_create ) 
              GetProcAddress( hLibrary, "_ca_context_create@4" );
          myassert ( pF_ca_context_create );

          p_ca_context_destroy pF_ca_context_destroy = ( p_ca_context_destroy ) 
              GetProcAddress( hLibrary, "_ca_context_destroy@0" );
          myassert ( pF_ca_context_destroy );

          p_ca_create_channel pF_ca_create_channel = ( p_ca_create_channel ) 
              GetProcAddress( hLibrary, "_ca_create_channel@20" );
          myassert ( pF_ca_create_channel );

          p_ca_clear_channel pF_ca_clear_channel = ( p_ca_clear_channel ) 
              GetProcAddress( hLibrary, "_ca_clear_channel@4" );
          myassert ( pF_ca_clear_channel );

          p_ca_pend_io pF_ca_pend_io = ( p_ca_pend_io ) 
              GetProcAddress( hLibrary, "_ca_pend_io@8" );
          myassert ( pF_ca_pend_io );

          int status = ( *pF_ca_context_create ) 
              ( ca_disable_preemptive_callback );
          MYSEVCHK ( status, "context create failed" );

      /*
          chid chan;
          status = ( *pF_ca_create_channel ) 
              ( "DTL_Diag:ND130:FaWave", 0, 0, 0, &chan );
          MYSEVCHK ( status, "create channel failed" );

          status = ( *pF_ca_pend_io ) ( 10.0 );
          MYSEVCHK ( status, "channel connect failed" );

          status = ( *pF_ca_clear_channel ) ( chan );
          MYSEVCHK ( status, "channel clear failed" );
      */

          ( *pF_ca_context_destroy ) ();

          FreeLibrary( hLibrary);
      }

  	return 0;
  }


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

To manage notifications about this bug go to:
https://bugs.launchpad.net/epics-base/+bug/541239/+subscriptions

Navigate by Date:
Prev: [Bug 541330] Re: 'assert (size <= ntohs ( pMsg->m_postsize ))' failed in ..caserverio.c line 344 Andrew Johnson via Core-talk
Next: [Bug 1815908] Re: casExpandRecvBuffer modifies the contents of the buffer mdavidsaver via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
Navigate by Thread:
Prev: [Bug 541330] Re: 'assert (size <= ntohs ( pMsg->m_postsize ))' failed in ..caserverio.c line 344 Andrew Johnson via Core-talk
Next: [Merge] ~anj/epics-base/+git/base-3.15:epics-prove into epics-base:3.15 Andrew Johnson via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
ANJ, 17 Oct 2019 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·