02-03-2025 03:13 AM
Hey. I'm building a VI that uses recursion to calculate Fibonacci series. I set-up the execution type of VI to shared clone reentrant. While running the VI, I'm getting a compilation error which says "You must have a VI that uses shared reentrancy or dynamic dispatching in any recursive cycle. For recursive calls to work, all VIs in the cycle should be reentrant and at least one must use dynamic dispatching or shared reentrancy.". I found a variety of solutions to this problem namely changing the call setup to either reload with caller or load and retain on first call, enclosing the content of my VI inside a structure, using in place element structure, etc. But my question is why the error occurred. I've attached the VI for reference. In the attached VI, in True case, if the wire to the indicatior is wired to the tunnel to which the control "Curr" is connected to, this works. But not when it is connected to "Prev" control. Why this happens? Thanks in advance.
02-03-2025 08:52 AM
Funnily enough, it works when a completely pointless numerical display is added.
02-03-2025 09:07 AM
Hey Martin_Henz, Thanks for the reply. This works even if you change the data type of the indicator also! I wonder how this works and why this happens?
02-03-2025 09:25 AM
@Martin_Henz wrote:
Funnily enough, it works when a completely pointless numerical display is added.
Interesting. I've had something happening a few years ago where the optimization was too aggressive and removed stuff i was actively probing. I wonder if this is something similar.
02-03-2025 09:54 AM - edited 02-03-2025 10:20 AM
To find Fibonacci numbers, it is simpler (and probably much more efficient!) to just have one flat diagram, though.
(I learned LabVIEW way before recursion was even allowed or shared clone available and won't comment 😄 )
If you really want a recursive solution, have a look here.
02-03-2025 09:46 PM
@dhanushtd wrote:
I wonder how this works and why this happens?
Mabe someone at NI can look for this issue and can explain why this happens. Shure, it should not happen. You can use any of the funny workarounds or use a non-reentrant algorithm (reentrant algorithms in laview are not fast).
02-07-2025 08:05 AM
@Martin_Henz wrote:May be someone at NI can look for this issue and can explain why this happens.
Who can I ask this or where can I ask this question so that someone can answer this?
02-07-2025 10:20 AM
It looks like a subtle compiler bug, and I have posted a note in the annual bug thread.