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  2023  2024  <2025 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  2023  2024  <2025
<== Date ==> <== Thread ==>

Subject: Re: Forking EPICS processes
From: Michael Davidsaver via Tech-talk <tech-talk at aps.anl.gov>
To: Grzegorz Kowalski <grzegorz.kowalski at ess.eu>
Cc: tech-talk at aps.anl.gov
Date: Sat, 8 Feb 2025 19:19:48 -0800
On 2/5/25 07:00, Grzegorz Kowalski wrote:
Hello,

I'm loading libCom, libdbCore and pvxs dynamically.
 From the backtrace it seems epicsThreadInit is called by dynamic loader when loading libCom:
...
Looking at the issue you linked it should be safe to fork since my main process is single-threaded and doesn't use any EPICS APIs.
Is that the case, or is there more to it?

What you suspect is probably the case, at least as long as
nothing goes wrong and triggers the errlog thread to start.

Also, this specific global contructor is one which I have a PR
to remove.  I would appreciate testing/feedback.

https://urldefense.us/v3/__https://github.com/epics-base/epics-base/pull/451__;!!G_uCfscf7eWS!ZWAEaCssmkBQsQ1-YFeKNlJ5UAw3irqFqZM3af3rTB7IYsMs4AriogLuMnMcGiJ1xXblCia600KlCFerrUd-QBjNAQ$
I should make clear though.  There are still a few other global
constructors, so this PR by itself will likely not make this
warning go away for you.  However, it is a step in that direction.


--
Pozdrawiam / Kind regards,
Grzegorz Kowalski

Den 2025-02-04 kl. 20:00, skrev Michael Davidsaver:
On 2/4/25 05:24, Grzegorz Kowalski via Tech-talk wrote:
Hello,

I'm working on a multiprocess application using EPICS.
My main process only reads the configuration and spins up child processes where EPICS is actually used.
However, when forking I get this warning:

Warning: Undefined Behavior!
          Detected use of epicsThread from child process after fork()

Is there a way to avoid starting any epicsThreads in the main process and only do so in a child process that needs them?

To answer this, we would have to know more about your application.
Which of the Base libraries you are loading, and how.  What calls
are made...

If your code is linked as a single executable, I would suggest loading
that executable in GDB add setting a break point for epicsThreadInit()
to see how it is called.

for reference:

https://urldefense.us/v3/__https://github.com/epics-base/epics-base/issues/211__;!!G_uCfscf7eWS!ZWAEaCssmkBQsQ1-YFeKNlJ5UAw3irqFqZM3af3rTB7IYsMs4AriogLuMnMcGiJ1xXblCia600KlCFerrUeStKhnFg$


References:
Forking EPICS processes Grzegorz Kowalski via Tech-talk
Re: Forking EPICS processes Michael Davidsaver via Tech-talk
Re: Forking EPICS processes Grzegorz Kowalski via Tech-talk

Navigate by Date:
Prev: Re: about css Michael Davidsaver via Tech-talk
Next: Re: PVA Gateway issues with two networks client Michael Davidsaver 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  2023  2024  <2025
Navigate by Thread:
Prev: Re: Forking EPICS processes Grzegorz Kowalski via Tech-talk
Next: PVA Gateway issues with two networks client Saisrikiran Mudigonda 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  2023  2024  <2025
ANJ, 08 Feb 2025 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions ·
· Download · Search · IRMIS · Talk · Documents · Links · Licensing ·