Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[minor] Update Client Generator helpers to replace tunnels in loops and prevent reference leak #634

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

varshini-senthil
Copy link
Contributor

@varshini-senthil varshini-senthil commented Feb 13, 2025

  • This contribution adheres to CONTRIBUTING.md. (Required)
  • Automatically post PR comments with images for G code changes? (Recommended for small changes)

What does this Pull Request accomplish?

  • Updates Cleanup Client If Error.vi and Update Measurement from Metadata.vi to replace the error wire tunnels in for loops with shift registers, as using tunnels for error wires might lead to the loss of the error source if the loop does not execute even once.

  • Updates the Client Generator helper VIs Copy Client Template Library.vi, Update Control from Metadata.vi, Update Measurement from Metadata.vi, Get Default Value.vi and Create Control.vi to prevent reference leaks.

    Context:
    While integrating Generate Client.vi into our application, we encountered 1357 and 1051 errors during testing when trying to create client (with same name) multiple times for a measurement.

    • 1357: A LabVIEW file from that path already exists in memory or within a project library already in memory. To resolve this error, give the file a path that does not already contain a LabVIEW file in any open application instance.
    • 1051: A LabVIEW file of that name already exists in memory or within a project library already in memory. To resolve this error, give the file a unique name that does not already exist in the application instance.

    Upon debugging, we discovered that these conflicts were caused by certain VI reference leaks in the helper VIs of the application. These leaks caused the generated client libraries to remain in memory under LabVIEW's Items in Memory, leading to conflicts when attempting to create a new client with the same name. Additionally, we found that there are certain VI reference leaks in the Copy Client Template Library.vi and few other helper VIs of the Client Generator as well.

    Although the VI reference leaks in the Client Generator helper VIs do not currently impact functionality, it is advisable to close these references appropriately after use to prevent any unexpected behavior in the future.

Why should this Pull Request be merged?

To update Client Generator helper VIs to replace the error wire tunnels in for loops with shift registers and to prevent VI reference leaks.

What testing has been done?

Built package for the changes and tested the wrapper VI for the mentioned scenario and also using the 'Desktop Execution Trace Toolkit'.

Copy link

0 of 3 files processed successfully.
Processed Cleanup Client If Error.vi: ERROR 1
Error 1 occurred at Check Data Size.vi

Possible reason(s):

LabVIEW: (Hex 0x1) An input parameter is invalid. For example if the input is a path, the path might contain a character not allowed by the OS such as ? or @.

Command requires GPIB Controller to be Controller-In-Charge.

Complete call chain:
     Check Data Size.vi
     Write PNG File.vi
     Graphical Diff.lvlib:Merge Diff Images.vi
     Graphical Diff.lvlib:Process Diff Images.vi
     Graphical Diff.lvlib:run_diff.vi
     RunVI.lvclass:RunOperation.vi:5910001
     CoreOperation.lvclass:CallRunOperation.vi:4230002
     ExecuteRunOperation.vi:5250001
     ExecuteOperation.vi:6900002
     ExecuteOperation.vi.ProxyCaller
Diff images generated for Source/Generator/Measurement V2 Client Generator Runtime/Cleanup Client If Error.vi.
Attribute Changes
     None

Processed Copy Client Template Library.vi: ERROR 1
Error 1 occurred at Check Data Size.vi

Possible reason(s):

LabVIEW: (Hex 0x1) An input parameter is invalid. For example if the input is a path, the path might contain a character not allowed by the OS such as ? or @.

Command requires GPIB Controller to be Controller-In-Charge.

Complete call chain:
     Check Data Size.vi
     Write PNG File.vi
     Graphical Diff.lvlib:Merge Diff Images.vi
     Graphical Diff.lvlib:Process Diff Images.vi
     Graphical Diff.lvlib:run_diff.vi
     RunVI.lvclass:RunOperation.vi:5910001
     CoreOperation.lvclass:CallRunOperation.vi:4230002
     ExecuteRunOperation.vi:5250001
     ExecuteOperation.vi:6900002
     ExecuteOperation.vi.ProxyCaller
Diff images generated for Source/Generator/Measurement V2 Client Generator Runtime/Copy Client Template Library.vi.
Attribute Changes
     None

Processed Update Measurement from Metadata.vi: ERROR 1
Error 1 occurred at Check Data Size.vi

Possible reason(s):

LabVIEW: (Hex 0x1) An input parameter is invalid. For example if the input is a path, the path might contain a character not allowed by the OS such as ? or @.

Command requires GPIB Controller to be Controller-In-Charge.

Complete call chain:
     Check Data Size.vi
     Write PNG File.vi
     Graphical Diff.lvlib:Merge Diff Images.vi
     Graphical Diff.lvlib:Process Diff Images.vi
     Graphical Diff.lvlib:run_diff.vi
     RunVI.lvclass:RunOperation.vi:5910001
     CoreOperation.lvclass:CallRunOperation.vi:4230002
     ExecuteRunOperation.vi:5250001
     ExecuteOperation.vi:6900002
     ExecuteOperation.vi.ProxyCaller
Diff images generated for Source/Generator/Measurement V2 Client Generator Runtime/Update Measurement from Metadata.vi.
Attribute Changes
     None

@varshini-senthil
Copy link
Contributor Author

Code diff images
Copy Client Template Library.vi
Before:
image

After:
image

@varshini-senthil
Copy link
Contributor Author

Code diff images:
Update Measurement from Metadata.vi
Before:
image

After:
image

@varshini-senthil
Copy link
Contributor Author

Code diff images
Cleanup Client If Error.vi
Before:
image

After:
image

@ni ni deleted a comment from github-actions bot Feb 13, 2025
@ni ni deleted a comment from github-actions bot Feb 13, 2025
@varshini-senthil
Copy link
Contributor Author

varshini-senthil commented Feb 19, 2025

Code changes
Update Control from Metadata.vi

  • Updated the VI to keep the vi refnum input open and pass it out, so the caller can handle closing the reference.

image
image

Update Measurement from Metadata.vi

  • Updated to handle reference closure outside the for loop to prevent reference leaks. The loop terminates when there are no measurement results, causing a reference leak for other file references.

image
image

Get Default Value.vi

  • Updated to align with the changes made to Update Control from Metadata.vi, ensuring the reference is closed in the caller and also to open reference to the 'Configuration.ctl' only when the measurement plug-in has a 'Measurement Configuration.ctl' control.

image

Create Control.vi

  • Updated to close reference of the ni.protobuf.types.DoubleXYData source object in 'TYPE_MESSAGE' case.
    image

@varshini-senthil varshini-senthil marked this pull request as ready for review February 20, 2025 19:20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Using a terminal name of vi refnum in for symmetry with vi refnum out is a little more standard than just vi refnum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants