G-CODE Posted September 12, 2020 Report Share Posted September 12, 2020 I was experiencing a whole host of problems running an application in LabVIEW 2020 (32-bit) dev environment. This function was giving me the wrong output. After an edit and save, the output of the function now appears correct. This is the first time I have ever seen this... 2020-09-11_17-18-49.mp4 Quote Link to comment
hooovahh Posted September 14, 2020 Report Share Posted September 14, 2020 Oh man that looks like a painful thing to debug and isolate. And an even bigger pain to convince NI that there is an issue when someone in the support call will just have a goal of getting your code working. I haven't seen anything in 2020 like this yet. I have seen code that application builder says is broken, I go and run the VI it isn't broken, and then the build can continue. It is related in that it seems to be a compiler issue. Quote Link to comment
X___ Posted September 14, 2020 Report Share Posted September 14, 2020 NI recommends to force recompile (mass compile) after each update. Quote Link to comment
G-CODE Posted September 14, 2020 Author Report Share Posted September 14, 2020 This happened on a virtual machine that only had LabVIEW 2020 installed. VIPM was always configured to mass compile VIs after package installation. If this happened even when packages were being mass compiled, what else is lurking under the hood waiting to be found? I want to assume that had I built an EXE in this state, this problem would have gone away. Quote Link to comment
X___ Posted September 14, 2020 Report Share Posted September 14, 2020 Gotcha. That is problematic. Quote Link to comment
Antoine Chalons Posted February 4, 2021 Report Share Posted February 4, 2021 out of the blkue, this issue just appeard on my LV2019 after installing LV2020 😮 Thx for publishing the fix. Quote Link to comment
Popular Post Jim Kring Posted February 4, 2021 Popular Post Report Share Posted February 4, 2021 (edited) Good news! There's a new release available on vipm.io with a fix. https://www.vipm.io/package/oglib_string/#4.1.1.16 The issue We were able to figure out what the issue is. It appears to be caused when using a NI Linux RT target. The problem seems to happen when LabVIEW compiles/saves 1D Array to String for running on an NI Linux RT target. Then, when you open and run 1D Array to String on Windows, it isn't always getting recompiled correctly. More Details The current implementation of 1D Array to String uses an EOL constant () to build a regular expression -- the EOL is platform dependent (it's CRLF "\r\n" on Windows and LF "\n" on Linux and Mac). My guess is that somehow the LabVIEW compiler constant folded the regular expression that is the concatenation of the EOL constant and "$" into "\n$" (match a Line Feed at the end of the string). However, on Windows the EOL character we are looking for is a CRLF ("\r\n") at the end of the string. So, if we were searching for "\n$" at the end, the before string would have a "\r" at the end of it, which is what we're seeing (when the bug is happening). Editing and re-saving this VI on Windows causes it to be recompiled and the regular expression get's correctly compiled and constant folded into "\r\n$" A More Robust Implementation (work-around) Looking at that 1D Array to String code, I don't really love how it's building the regular expression using an EOL constant. I think that a more robust solution would just build the regular expression as "[\r\n]+$" (one or more Carriage Return or Line Feed characters at the end of the string). This would be platform independent and not suffer from the compiler bug we're discussing here. There's a new release available on vipm.io with this fix. https://www.vipm.io/package/oglib_string/#4.1.1.16 [Update] I've opened a service request with NI to dig into it some more. I'll post updates, once I find out more. Edited February 4, 2021 by Jim Kring 1 2 Quote Link to comment
Rolf Kalbermatter Posted February 5, 2021 Report Share Posted February 5, 2021 17 hours ago, Jim Kring said: The current implementation of 1D Array to String uses an EOL constant () to build a regular expression -- the EOL is platform dependent (it's CRLF "\r\n" on Windows and LF "\n" on Linux and Mac). LabVIEW for Mac OS Classic used actually a "\r" character for this, since the old MacOS for some reason was using yet another EOL indicator. Quote A More Robust Implementation (work-around) Looking at that 1D Array to String code, I don't really love how it's building the regular expression using an EOL constant. I think that a more robust solution would just build the regular expression as "[\r\n]+$" (one or more Carriage Return or Line Feed characters at the end of the string). This would be platform independent and not suffer from the compiler bug we're discussing here. This is strictly speaking not equivalent to the originally intended implementation since this would remove multiple empty lines at the end while the original one only removed one EOL. However the Array to Spreadsheet String function should not produce empty lines (except maybe if you enter a string array of n * 0 elements) but that does not apply for this 1D array use case. Quote Link to comment
Jim Kring Posted February 5, 2021 Report Share Posted February 5, 2021 2 hours ago, Rolf Kalbermatter said: This is strictly speaking not equivalent to the originally intended implementation since this would remove multiple empty lines at the end while the original one only removed one EOL. However the Array to Spreadsheet String function should not produce empty lines (except maybe if you enter a string array of n * 0 elements) but that does not apply for this 1D array use case. You're right, Rolf. I can see some situations where my proposed "fix" would fail -- if the last element(s) of the Array of Strings intentionally contains EOL characters at the end ["\t", "\r", "\n"] Now, looking at the "1D String Array to Delimited String.vi" that got added to LabVIEW (I'm not sure which version), we see it has a similar implementation (although it doesn't use Match Pattern and simply removes the calculated length of the EOL at the end of the string). I wonder if this VI suffers from the same constant folding compiler bug reported in this thread (I'm going to do some testing). This all makes me wonder if we should be creating the delimited string in a more low-level way (instead of relying on the Array to Spreadsheet String function, which adds the EOL at the end). Here's a simple solution: And, here's a potentially more performant solution for larger strings: Thoughts about the best approach here? Quote Link to comment
Jim Kring Posted February 5, 2021 Report Share Posted February 5, 2021 Here's another potential "fix" that simply aims to work around the compiler bug and doesn't deviate from the original implementation (which helps avoid any unintended changes in behavior that might be caused by a new implementation). 1 Quote Link to comment
Jim Kring Posted February 5, 2021 Report Share Posted February 5, 2021 We've figured out more information. The problem seems to go away if you turn ON "Separate compiled code from source file" for 1D Array to String Meaning: the problem occurs when the compiled code is saved in the VI source file. It would seam that LabVIEW is not correctly determining when it needs to recompile/save the VI when switching between RT and Windows. Quote Link to comment
Jim Kring Posted February 5, 2021 Report Share Posted February 5, 2021 OK, here's a game plan I think will work to fix the issue, yet without changing the behavior of the code. Since LV2009 (the version of LabVIEW the package is currently developed in) doesn't have the "Separate compiled code" feature), we'll implement a work-around by creating a special subVI to get the EOL that is not affected by the bug (Note: ignore the fact that the screenshot shows this VI open in LV2020). We'll do this by calling the Array to Spreadsheet string function with empty string inputs. It appears from testing that this does not get constant folded (or at least is not impacted by the bug). And, we'll cache this value for performance on subsequent calls. It'll all be packaged into a tidy little sub-VI, so that it's obvious what we're doing and why. I've released this as version 4.1.2.18. Moving forward, we'll upgrade the sources for this package to LV2013 and mark all the VIs for "Separate from compiled code". We would have done that sooner, but there was a build issue in 2013, due to the fact that NI introduced a VI called "Trim Whitespace.vi" that shares the same filename and thus collides with the OpenG VI (in source code form before it's name mangled in the build process). But, that's a different story (and I think we can work around it during the build process)... 1 Quote Link to comment
Jim Kring Posted February 11, 2021 Report Share Posted February 11, 2021 This bug has been submitted to NI and confirmed. bug number 1289111 1 1 Quote Link to comment
rtollert Posted June 25, 2021 Report Share Posted June 25, 2021 We think we got 1289111 licked in LabVIEW 2021. 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.