LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Open Shared Variable Function Crashes Executable

Solved!
Go to solution

I have a program that is programmatcially connecting to Network Published PSP variables on a crio. Its a fairly simple application so I am directly communicating with the I/O channels by publishing their data with Scan engine.

 

My project is working fine when in developer mode but does not work after building an executable.  The executable does not error, it completely locks up and I am forced to "End Task" within windows.  Without errors it was a pain, but I have finally traced this behavior down to this portion of my code.  

 

I open the connection within a shared clone reentrant class method that I use for initializing sensor data.  I'm not sure if the open variable function does not support using calling it within a class method this way or if this is just some weird bug. I have built smaller test executables using just the open variable function that seem to work fine when run.  I have also tried non-reentrant execution with the same effect.  

 

 

Open Variable.png

 

 

 I'm also wondering if my Run Time engine could be corrupted, but I'm not sure how to check that as this executable is on my development computer.  I can't seem to find a way to re-install the runtime without completely removing LV2012 and starting from scratch.  Thanks Smiley Sad

 

0 Kudos
Message 1 of 8
(2,822 Views)

I have finally isolated the source of my executable crash and I believe it is a BUG within labview itself however, I do not have an way to verify on a different OS or system.  Is there a forum or bug report form I can fill out?  

 

Opening a variable connection programmatically within a time-loop is causing Labview built executable's to crash on my computer.  You must have a variable connection to replicate this problem.  I currently have network published psp variable on a crio that I am connecting to.  If I replace the time loop with a normal while loop, the executable will not crash and functions normally.  I do not think this is normal behavior of the time loop as it works just fine in development mode.    

 

Open Variable.png

 

 

I have attached a sample project.  I am currently running Win XP and LV 2012 f1, however, I was able to replicate this bug in 2011 SP1 as well.  

0 Kudos
Message 2 of 8
(2,803 Views)

One question I have is why are you repeatedly opening a shared variable reference in a loop?  You are opening the reference and never closing it.  You should be opening it once outside the loop, using it repeatedly in the loop, and closing it after the loop.  I don't know if what you are doing would cause the particular crash you are seeing, but I can certainly see it being a problem in LabVIEW of continually opening up a resource and never closing it.

0 Kudos
Message 3 of 8
(2,801 Views)

@OriolesFan wrote:

One question I have is why are you repeatedly opening a shared variable reference in a loop?  You are opening the reference and never closing it.  You should be opening it once outside the loop, using it repeatedly in the loop, and closing it after the loop.  I don't know if what you are doing would cause the particular crash you are seeing, but I can certainly see it being a problem in LabVIEW of continually opening up a resource and never closing it.


Sorry this was a really simple test case i put together very quickly and your points are valid. Not my best example code, however, if do things the right way i still get the same executable crash.  

 

The following code causes and executable crash when built and run.

 

Open Variable 1.png

 

 

 

This code works when built and run:

 

Open Variable 3.png

 and either does this one.  

 

 Open Variable 2.png

 

 

 

0 Kudos
Message 4 of 8
(2,799 Views)

You'll notice there's a coersion dot on the input to the right shift register. The Open function outputs a slightly different type than it takes in.

 

First data type:

inputrefnum.png

 

Second data type:

Outputrefnum.png

 

It will work great if the shift register's data type is correct.

Craig H. | CLA CTA CLED | Applications Engineer | NI Employee 2012-2023
Message 5 of 8
(2,773 Views)

 

@craig-H wrote:

You'll notice there's a coersion dot on the input to the right shift register. The Open function outputs a slightly different type than it takes in.

 

First data type:

inputrefnum.png

 

Second data type:

Outputrefnum.png

 

It will work great if the shift register's data type is correct.


I guess i'm confused b/c my first example doesn't work either and it still crashes if i only open and write once in the loop and don't use a shift register.  You still have the same coerssion dot when using a non-timed while loop as well.  I've moved on after replacing the timed loop with a non-timed while loop for the time being, i have a project to finish and can't trouble shoot this till its done.  It is most likely an issue with my computer.  

0 Kudos
Message 6 of 8
(2,763 Views)

While the wire is the same for both references they contain different data types, meaning that the shared variable refnum coming into "Open Variable Connection" is slightly different than the type that is coming out.

 

Your code works where the shift register's type is initialized to the refnum after it comes out of the open function and my guess is that your class's cluster is referencing the initial type as well.

 

The functionality is definitely a little bit confusing and the way the refnums change does not make it easy to use them within classes. It is also wierd how execution changes between timed and non-timed loops.

Craig H. | CLA CTA CLED | Applications Engineer | NI Employee 2012-2023
0 Kudos
Message 7 of 8
(2,758 Views)
Solution
Accepted by Jed394

Just an update to this forum, I've been working with John on a service request related to this forum, and I have been unable to reproduce this crash on Windows 7 or Windows XP (LabVIEW 2012). 

Colden
0 Kudos
Message 8 of 8
(2,729 Views)