Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with nidaqmx/Python/Linux in Threaded Application

Hello,

 

I am developing an application for Python 3.7.3 (built from source with gcc-7.3.1) that incorporates nidaqmx for data acquisition. From the main thread, the application spawns a separate thread to start the task of data collection. A small number of other threads are also spawned to perform non-DAQ related monitoring and some of those threads are using Python's subprocess.Popen.

 

Recently on a CentOS 7 machine with a PCIe-6353, I started seeing issues where my application would terminate with a segmentation fault. I have developed a few small scripts that I believe reproduce the issue. These are attached.

 

  • shared.py: Lightweight module that is imported by the scripts listed below.
  • single_thread.py: Script that shows the DAQ will collect data if it runs in the main thread.
  • multi_thread.py: Script that tries to execute a read task in a separate thread from main. Immediately after that task is started, the main thread enters a for-loop that repeatedly creates and runs subprocess.Popen objects. The first subprocess runs successfully. The second subprocess leads to a segmentation fault. However, the DAQ seems to collect data in the second thread without any issues (except that the main thread cannot retrieve the data).
  • multi_process.py: Script that tries to execute a read task in a separate process entirely. Immediately after that process is started, the main process enters a for-loop that repeatedly creates and runs subprocess.Popen objects. In this case, the main process seems okay. The process in which the read task should occur leads to a segmentation fault.

Using gdb to dig into the core dumps for the multi_thread.py and multi_process.py scripts, respectively, this is what I observe:

 

Program terminated with signal 11, Segmentation fault.
#0  __malloc_fork_unlock_child () at arena.c:303
303         mutex_init(&ar_ptr->mutex);
Program terminated with signal 11, Segmentation fault.
#0  0x00007f14ae2e4a8b in ?? () from /usr/lib/x86_64-linux-gnu/libnipalu.so.1

I am wondering if anyone has observed issues like this before and if and how you were able to resolve them, if at all. Perhaps I've misunderstood how nidaqmx can be integrated using concurrency.

 

Much appreciated,

--Brent

0 Kudos
Message 1 of 3
(2,185 Views)

Have you been able to reproduce this with other hardware & python versions?

0 Kudos
Message 2 of 3
(2,026 Views)

On other hardware? No, we (the team to which I belong) have not tried. But on other versions of Python? Yes, all of them that we have tried. I should have noted in my original post that we do not experience these issues running this same application on a Windows host.

 

I am currently engaged with NI Technical Support on this issue. I will update when something concrete comes from that.

0 Kudos
Message 3 of 3
(2,018 Views)