On 05/02/2025 12:00, Grzegorz Kowalski via Tech-talk wrote:
Hello,
Hi Grzegorz,
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?
As you saw, the thread initialization function doesn't run when you
first call an EPICS API, it runs when you dlopen the library (there's a
mechanism to register functions to be run when libraries are loaded and
unloaded). So loading the library already initializes it for your
current program.
I assume you're opening the libraries before forking, in order to fail
early? I'd try moving the dlopen call to after forking. I'd expect that
to fix the warnings.
--
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$
Aviso Legal: Esta mensagem e seus anexos podem conter informações confidenciais e/ou de uso restrito. Observe atentamente seu conteúdo e considere eventual consulta ao remetente antes de copiá-la, divulgá-la ou distribuí-la. Se você recebeu esta mensagem por engano, por favor avise o remetente e apague-a imediatamente.
Disclaimer: This email and its attachments may contain confidential and/or privileged information. Observe its content carefully and consider possible querying to the sender before copying, disclosing or distributing it. If you have received this email by mistake, please notify the sender and delete it immediately.