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  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  <20232024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  <20232024 
<== Date ==> <== Thread ==>

Subject: How to prevent deadlock for ca_clear_channel()
From: "Wang, Lin via Tech-talk" <tech-talk at aps.anl.gov>
To: tech-talk at aps.anl.gov
Date: Wed, 24 May 2023 16:55:28 +0800 (GMT+08:00)

Dear all,

In the Node.js single-threaded environment, if I load libca.so and call ca_clear_channel() after the user callback execution of ca_array_put_callback(), sometimes a deadlock occurs. After printing logs, I found that the code blocked at Line 391 of https://github.com/epics-base/epics-base/blob/7.0/modules/ca/src/client/access.cpp


390        //
391        CallbackGuard cbGuard ( cac.cbMutex );
392        epicsGuard < epicsMutex > guard ( cac.mutex );
393        pChan->destructor ( *cac.pCallbackGuard.get(), guard );
394        cac.oldChannelNotifyFreeList.release ( pChan );


In Channel Access reference manual, the description of ca_clear_channel() includes the following info,

Note: This operation blocks until any user callbacks for this channel have run to completion. If callbacks take a lock (mutex) then it is the user's responsibility to ensure that this lock is not held when ca_clear_channel() is called, otherwise a deadlock may ensue.


So my question is how to prevent the deadlock from users' side. In the following training link, the approach is to wait in ca_pend_event() for the callbacks to occur. Is there any other approach or idea besides just waiting enough time for callback to finish?

https://epics.anl.gov/docs/GSWE/developtools/EPICSTraining.IntroductionToChannelAccessClients.Handouts.pdf


Thanks,

Lin





Navigate by Date:
Prev: Re: makefile compilation question timesir via Tech-talk
Next: some motor driver 3 questions lynn via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  <20232024 
Navigate by Thread:
Prev: motor R7-3 released Kevin Peterson via Tech-talk
Next: some motor driver 3 questions lynn via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  <20232024 
ANJ, 24 May 2023 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·