QControl Enthusiasts

cancel
Showing results for 
Search instead for 
Did you mean: 

Q Control Race Condition

Hi all,

 

I've been using QControls extensively in my code base, and after intermittently encountering error 1556 (invalid reference), I believe there is a race condition in QControls.

 

To Recreate:

  1.) Add cleanup code to Event Handler which accesses the State Data DVR. The cleanup code must take some time to complete. You can add a delay here to make sure you encounter the race condition.

  2.) Run the QControl as you would normally

  3.) Close the QControl

  4.) The Event Handler should throw error 1556.

 

Reason:

The Close Event Handler VI doesn't wait for the Event Handler to close before closing the State Data DVR. If the Event Handler attempts to access the State Data after it has been closed, then Error 1556 (invalid reference) is thrown.

 

Proposed Solution:

  1.) Add a notifier to the Control.lvclass that notifies the Close Event Handler.vi when the Event Handler Dispatcher.vi is done executing.

  2.) Change Close Control.vi in Control.lvclass to Shared Clone Reentrant Execution. (This will require a bunch of other VIs which rely on this VI to change their reentrancy settings).

 

I have been personally running the above proposed solution for several months without issue. I made a GIT merge request a while ago, but I've just recently closed it after not getting a response for a long time and realizing the long reaching changes required by the reentrancy setting change. Here is the original merge request. It has images of proposed code changes included.

 

https://gitlab.com/QSI_Shared_Code/SharedQControls/QControlToolkit/-/merge_requests/1 

Nora Clark
0 Kudos
Message 1 of 2
(1,469 Views)

Nora,

 

I apologize for not getting back to you.  Thank you for posting this so that others that have this problem can fix it on their own.  I would still like to incorporate your changes into the main branch and will make it a priority this week to review your code.

 

Q

Quentin "Q" Alldredge

Chief LabVIEW Architect, Testeract | Owner, Q Software Innovations, LLC (QSI)
Director, GCentral | Admin, LabVIEW Wiki | Creator, The QControl Toolkit
Certified LabVIEW Architect | LabVIEW Champion | NI Alliance Partner



0 Kudos
Message 2 of 2
(1,432 Views)