viSci Posted March 24, 2013 Report Share Posted March 24, 2013 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 Quote Link to comment
GregFreeman Posted March 24, 2013 Report Share Posted March 24, 2013 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. Quote Link to comment
Jordan Kuehn Posted March 24, 2013 Report Share Posted March 24, 2013 Double confirmed. I also don't see anything amiss on the surface, but it's late and I'm headed to bed. (LV 2012 SP1 F1) Quote Link to comment
Yair Posted March 24, 2013 Report Share Posted March 24, 2013 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. 2 Quote Link to comment
viSci Posted March 24, 2013 Author Report Share Posted March 24, 2013 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. Quote Link to comment
Yair Posted March 24, 2013 Report Share Posted March 24, 2013 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. Quote Link to comment
viSci Posted March 24, 2013 Author Report Share Posted March 24, 2013 Well then I guess I was lucky that the main effect was LV crashing! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.