Jump to content

User Events and LabVIEW crashes


Recommended Posts

Here is a simple application that uses User Events to communicate with a single process running in a subpanel.  

I am finding that I cannot have both the main vi and the subpanel process both registered for the same set of events without

LV crashing.  If anyone would care to take a look I would appreciate it very much.  

Just unzip and run the Aircraft Emulator vi with one event enabled, observe the event generation and reception counters are keeping up with each other.

Now enable the 2nd event and watch LV crash.  BTW, I have tried running the process outside the subpanel and it still crashes.

 

TIA

Aircraft Emulator.zip

Link to comment

Confirmed. I don't see anything blatantly obvious that you're doing which would cause this. You aren't closing your references on shutdown, but this is crashing almost immediately. I did noticed if I slowed the bottom loop down I didn't have an issue, but I also didn't run it the same amount of iterations as the loop ran set at a 10 ms wait. Sorry for the limited testing, but I have atleast confirmed this. Someone else may see something you're doing that could cause this, but with my quick look nothing glaring popped out at me.

Link to comment

I do see something which is very wrong - you use the same event registration refnum for both event structures. That is a BIG no-no. If I change that and wire the cluster of event refnums into a separate register node, then there is no crash.

 

Now, I'm not saying that a crash is the right behavior here (because it isn't), but you should definitely change your code. If you use an event registration reference for more than one structure, you will get various irreproducible bugs, because the system wasn't designed to work that way.

 

There's a caveats section for events in the LV help which talks about this a bit, but the rule is simple - an event registration refnum should belong to only one event structure. The easiest way to enforce this is to always place the register node right next to the event structure itself, but you can also do the registration in a subVI and then bundle the reg refnums into the dynamic terminal. If you do that, make sure the VI outputs a different refnum for each call.

  • Like 2
Link to comment

Thanks Yair and others that replied.  I did find the caveat you mentioned.  For some reason I wishfully was thinking that LV was automagically creating a event queue at each event structure :)

 

From LV Help:

 

Make Sure You Have a Register For Events Function for Each Event Structure

 

If you wire the event registration refnum to more than one Event structure, each Event structure handles dynamic events out of the same event queue. This can occur if you branch the event reg refnum out output of a Register For Events function to another Event structure. This causes a race condition, because the first Event structure to handle the event can prevent the other Event structure from receiving the event if it completes the event case before the other Event structure executes.

To avoid this problem, make sure you wire each Event structure which handles dynamic events to a unique Register For Events function. 

Link to comment
This causes a race condition, because the first Event structure to handle the event can prevent the other Event structure from receiving the event if it completes the event case before the other Event structure executes.

 

That description makes the behavior sound a lot milder than it actually is. If you do this, you might find events disappearing completely or being handled by more than one ES at the same time. You might find event structures freezing for no apparent reason, etc. In short, like I said, a big no-no.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.