Jump to content

Typedef enum CONSTANT changes during execution


labviewman

Recommended Posts

I have a simple .vi that uses a queued state machine using typedef enum constants. A very common technique in a state machine.

What I didn't expect was the typedef enum constant (yes, a constant!) to change during execution. Quite a serious bug.

This was originally LV7.0 code, converted it to LV7.1 but the problem exists. I have not tried LV8.0 (haven't even taken it out of shrink wrap yet).

NI is looking into this, issue #7105073.

Todd

Download File:post-2108-1140486925.zip

Link to comment

I tried that before and it didn't work. I even re-created the type-def completely, and it didn't work.

What did work was to replace the 'enqueue element' at the problem location in the code.

Watch how tnhe constant changes during execution...then changes back when the program stops!

It didn't take long to track down this problem since the code from this was taken is quite simple.

I have a simple .vi that uses a queued state machine using typedef enum constants. A very common technique in a state machine.

What I didn't expect was the typedef enum constant (yes, a constant!) to change during execution. Quite a serious bug.

This was originally LV7.0 code, converted it to LV7.1 but the problem exists. I have not tried LV8.0 (haven't even taken it out of shrink wrap yet).

NI is looking into this, issue #7105073.

Todd

Link to comment
I suspect is a casting problem, something usual with enums. In fact, if you explicitly typecast the constant to U16 the problem dissapears... So in some step LV doesn't know what representation is that control.

Unfortunately I have no more time today, tomorrow I'll check it more deeply.

Saludos,

Aitor

I took a quick peek at this the other day and it reminds me of a similar "form" of bug that involved a cluster. It looks like the optimization and buffer re-use logic is out of whack. The original buffer holding the constant is being updated instead of copied. Code changes that force execution order can help. Looks like constant folding is out of control.

Just my quick guess,

Ben

Link to comment
The original buffer holding the constant is being updated instead of copied.

Yes, that's true. And I think the problem is located in the queue creation. If you just rewire it or wire another copy of the enum constant, the problem solves. So I suspect that first constant set to "key id" is corrupt and, from that point, LV loses a valid reference to the object and what the heck it is.

In fact, if we knew how to reproduce this, it would be really interesting to change constants in run time ;)

Saludos,

Aitor

Link to comment
Yes, that's true. And I think the problem is located in the queue creation. If you just rewire it or wire another copy of the enum constant, the problem solves. So I suspect that first constant set to "key id" is corrupt and, from that point, LV loses a valid reference to the object and what the heck it is.

In fact, if we knew how to reproduce this, it would be really interesting to change constants in run time ;)

Saludos,

Aitor

Paraphrasing a posting by Rolf years ago....

"Self- modifying code is a very bad idea." :nono:

OT > AK2DM

I am finding it hard to navigate without the stars. ;)

Ben

Link to comment
Paraphrasing a posting by Rolf years ago....

"Self- modifying code is a very bad idea." :nono:

OT > AK2DM

I am finding it hard to navigate without the stars. ;)

Ben

I know that I said that there are no stars here, but it was slightly changed since then. If you really want to give stars, each thread has a Rating button hiding on top, which rates the entire thread.

Personally, I find the NI forums much easier to use than the LAVA forums (even though LAVA has a significantly larger number of features). This is mostly because the NI forums have a much cleaner design (simple colors, mostly text) and because there it is easier to follow when things get posted (since LAVA is influenced by your logins and not by whether you actually read the posts). As long as LAVA doesn't have too much activity, though, it's not too much to handle. Thanks, Michael and team.

Link to comment
Paraphrasing a posting by Rolf years ago....

"Self- modifying code is a very bad idea." :nono:

Not necessarily the same VI, but between them. Here the .ctl is in fact working as a external variable, in a very simple manner. Maybe this works between different runtimes too, all accessing the same type definition. Well, OK, probably not :rolleyes: .

Saludos,

Aitor

Link to comment
Here is NI's response:

-------

R&D have identified your issue as a bug and it will be fixed in the next release/patch for LabVIEW. Please let me know if you have any other questions about this issue.

-------

I have added this thread to the official NI BUg List that can be found here.

http://forums.ni.com/ni/board/message?boar...message.id=1882

For those of you that do not frequent the NI Developer Exchange I want to make sure you are aware that the NI Bug List is now Official as I mention here. (See reply #20).

http://forums.ni.com/ni/board/message?boar...message.id=1698

The Official NI Bug list should NOT be viewed as competition for the LAVA Bug List. It should be viewed as a compliment of same.

"Keep them bug and letters coming!"

Ben

Link to comment

Hi,

I've tried to strip the VI smaller and keep the problem. It seems that the problem boils down to the type connected to Create Queue. The constant seems to be "corrupt". Modifying its type definition or changing it to a constant does not resolve this, but when you re-create it it's fixed.

Joris

Download File:post-1555-1141826795.vi

Download File:post-1555-1141826825.ctl

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.