Machine Vision

Showing results for 
Search instead for 
Did you mean: 

Labview crashing with vision application


I've have a fairly small vision application and the vision VIs keep crashing labview.

Everything used to be in a single loop, and it worked in that setup, but the complexity is growing that model was becoming unmanageable, so I set up parallel loops.  When I finished that, labview started to crash.

At first labview would report that an external library had thrown an exception.  IMAQ Copy was normally the offending VI, but other vision functions would throw exceptions.  IMAQ Read Custom Data was fairly common.  These exceptions were common, usually happening within a minute of starting the VI.

Since image refnums are basically pointers in labview, I had used a semaphore to prevent the acquisition loop from writing over an image that another part of the program was reading.  When I saw the errors, I modified the program to prevent any two parts of the program from reading the image at the same time (even though it seems that should be safe).   That change made the errors much less common, but they would still happen occasionally.

(and to make things more interesting, I let the program run for hours with execution tracing turned on so I could see which IMAQ copy was causing the exception, and it didn't crash once.)

Does anybody know how to debug exceptions in the vision library?

Also, recently, the annoying error messages have gone away and labview has just started crashing without any kind of warning.

Does anybody know a method for debugging labview when the process just dies?


Thank you,

Adam Brewster

Message 1 of 9

Hi Adam

It looks like parts of Labview are corrupted. Did you made an update of LabVIEW between the 2 versions of the application ? It could be that you messed up labview versions by using old VIs.

Whatever the origin, I would :

1 - Make a mass compile of the application.

2 - If it doesn't help, try to repair labview from the installation parts.


Hope this helps. If you want I can have a look at your VI

Please take time to rate this answer
Message 2 of 9
Thanks for the quick reply.

I didn't make any changes to labview or any other NI software while I was doing this rewriting, but I'll try repairing the installation and mass compiling.

0 Kudos
Message 3 of 9

try mass compiling first (it is much faster) !




Smiley Wink

Please take time to rate this answer
Message 4 of 9
After reinstalling labview, the vision package, and the camera drivers, and mass compiling vi.lib and my application, labview still crashes when I run my application.
0 Kudos
Message 5 of 9
can you show me you app if it is neither secret nor too big?
Please take time to rate this answer
Message 6 of 9

The application is a little big to show screenshots of the relevant sections, and I can't post the actual code.

I found one problem that I thought was causing this: I had used a semaphore to protect access to the image that gets passed around the program, but I found another image that's used in more than one place.  I added another semaphore to protect the second image and everything seemed to work.

Just as I was typing out my reply that said "I found the problem" it crashed again.

Now I've got the exception dialog instead of labview just dying.

I guess I need to go through and look for any other images that might be getting passed between VIs.

Thank you for your help.

Message 7 of 9

For the benefit of those that may come across the same problem in the future:

It appears that there were two problems.

1 - Insufficient use of semaphores.  There were places in the application where the same image was accessed by multiple VIs simultaneously.  When this happened, labview just died without any error message.  Sometimes Dr Watson would pop up and ask me if I wanted to tell microsoft about the problem, but there was no exception dialog from labview.  I solved this problem by making sure that each call on a shared image (i.e. an image that was accessed from more than one VI) was protected by a semaphore.

2 - IMAQ library calls claim to be reentrant, but aren't.  Even after making sure that different sections of the code weren't working on the same image at the same time, the application would still die from time to time due to an exception in external code.  I was not able to get any more details about the exception, but it killed my program after about 5-10 minutes.  I tried just about everything I could think of to fix this without changing the library code, but nothing worked.  I was suspicious of the fact that none of the VIs are marked for reentrant execution, but all of the Call Library Function nodes are, so I opened each of the IMAQ VIs and set the Call Library Function nodes to "Run in UI Thread", and I haven't seen an exception since that time.

Once again, thanks to Doc-doc for helping me work this one out.

Adam Brewster

0 Kudos
Message 8 of 9
Great to read you solved the problem.
I would not recommend the use of semaphores in such a situation, I think it is not the best portable solution.
It would be much preferrable to force execution order of the VIs using dataflow : as you said, it is best practice to run vision VIs one after the other. So the usual way of proceeding is to always wire image in, error in and image out and error out. In this configuration, the next VI will execute only if the previous finished execution.
For re-entrant Vision VIs, I also noticed that sometimes they run as re-entrant but the picture data is mixed, so it is not recommended to use them that way.
Please take time to rate this answer
0 Kudos
Message 9 of 9