Experimental Physics and
This is a bug (or is it?) that involves libca, pyDevSup and pyepics. We use pyDevSup on some of our IOCs. On most of them, we also want to use pyepics.
Everything works fine until we issue exit() on the IOC shell. When that happens, the IOC segfaults.
I believe that the following are true:
- pyepics dynamically loads libca, which ends up being the same instance as the one loaded by the IOC itself (for dbCa)
- pyepics does not share the same context with dbCa if it is run on its own thread and the proper context_create call is performed
- Even when not sharing libca contexts, the variable caClientCallbackThreadId ends up being the same for pyepics and dbCa.
- cacExitHandler runs when the IOC is exiting and sets caClientCallbackThreadId=0 
- Any subsequent libca call by pyepics (during its cleanup) that tries to use caClientCallbackThreadId will segfault.
- Register pyepics' finalize_libca with pyDevSup's addHook('AtIocExit',...), but this runs after dbCa cleanup. Can it be made to run before? Can there be a 'BeforeIocExit' hook?
- Remove caClientCallbackThreadId=0 in libca. I have no idea about the implications.
- Something else?
Of course, I understand that both the IOC itself and pyepics kind of expect to be the sole users of libca in their processes. This assumption doesn't hold when I have pyepics inside a IOC.
|ANJ, 03 May 2019||
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·