EPICS Home

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: Grzegorz Kowalski via Tech-talk <tech-talk at aps.anl.gov>
To: Michael Davidsaver <mdavidsaver at gmail.com>
Cc: tech-talk at aps.anl.gov
Date: Wed, 5 Feb 2025 16:00:09 +0100
Hello,

I'm loading libCom, libdbCore and pvxs dynamically.
From the backtrace it seems epicsThreadInit is called by dynamic loader when loading libCom:

Breakpoint 1, epicsThreadInit () at ../osi/os/posix/osdThread.c:453
warning: Source file is more recent than executable.
453         int status = pthread_once(&once_control,once);
(gdb) bt
#0  epicsThreadInit () at ../osi/os/posix/osdThread.c:453
#1 0x00007ffff7c6066e in epicsThreadGetIdSelf () at ../osi/os/posix/osdThread.c:867
#2  0x00007ffff7c58688 in initMainThread () at ../osi/epicsThread.cpp:381
#3 0x00007ffff7c586c2 in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at ../osi/epicsThread.cpp:387 #4 0x00007ffff7c586e6 in _GLOBAL__sub_I_epicsThread.cpp(void) () at ../osi/epicsThread.cpp:387 #5 0x00007ffff7fc947e in call_init (l=<optimized out>, argc=argc@entry=3, argv=argv@entry=0x7fffffffe108, env=env@entry=0x7fffffffe128) at ./elf/dl-init.c:70 #6 0x00007ffff7fc9568 in call_init (env=0x7fffffffe128, argv=0x7fffffffe108, argc=3, l=<optimized out>) at ./elf/dl-init.c:33 #7 _dl_init (main_map=0x7ffff7ffe2e0, argc=3, argv=0x7fffffffe108, env=0x7fffffffe128) at ./elf/dl-init.c:117
#8  0x00007ffff7fe32ca in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#9  0x0000000000000003 in ?? ()
#10 0x00007fffffffe4d6 in ?? ()
#11 0x00007fffffffe506 in ?? ()
#12 0x00007fffffffe509 in ?? ()
#13 0x0000000000000000 in ?? ()

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?

--
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!chq3WQM4Zuci8wzS44XZTdz3EXDPmHEiOlkOfS9G0bAX1H0US7aTmMUxqGyjBneXAPW4635_1_ltyBdBwFCfoDu3ubQYrRE$

Replies:
Re: Forking EPICS processes Érico Nogueira Rolim via Tech-talk
Re: Forking EPICS processes Michael Davidsaver via Tech-talk
References:
Forking EPICS processes Grzegorz Kowalski via Tech-talk
Re: Forking EPICS processes Michael Davidsaver via Tech-talk

Navigate by Date:
Prev: Re: about css Eusebio Naif Al-Soliman Fuentes via Tech-talk
Next: Re: Forking EPICS processes Érico Nogueira Rolim 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 Michael Davidsaver via Tech-talk
Next: Re: Forking EPICS processes Érico Nogueira Rolim 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