CFFI's cffi_backend.FFI.dlopen creates a Segmentation fault (core dumped) when Python exits
I'm working with Python 3.7.1 (installed using Anaconda) on a CentOS7 system. I'm trying to control a National Instruments DAQ using the CFFI library.
Another project called PyDAQmx already accesses this library using the ctypes library. When PyDAQmx opens the file (using this code: https://github.com/clade/PyDAQmx/blob/master/PyDAQmx/DAQmxConfig.py#L69), the library is opened and there is no error. A standalone example:
import ctypes
from ctypes.util import find_library
lib_name = find_library
ctypes.cdll.LoadLibrary(lib_name)
# <CDLL 'libnidaqmxbase.so.15', handle 564d7aa3dea0 at 0x7f9c2989d9e8>
# ... main program ...
exit()
# No Seg Fault
When I try to do a similar thing using cffi
import _cffi_backend
from ctypes.util import find_library
lib_name = find_library
_cffi_backend.load_library(lib_name)
# <clibrary 'libnidaqmxbase.so.15'>
# ... main program ...
exit()
# Segmentation fault (core dumped)
Alternatively
import _cffi_backend
from ctypes.util import find_library
lib_name = find_library
args = [] # Defined elsewhere
kwargs = {} # Defined elsewhere
ffi = _cffi_backend.FFI(*args, **kwargs)
ffi.dlopen('libnidaqmxbase.so.15')
# <Lib object for 'libnidaqmxbase.so.15'>
# ... main program ...
exit()
# Segmentation fault (core dumped)