NI Home > Community > NI Discussion Forums

BreakPoint

Showing results for 
Search instead for 
Do you mean 
Reply
Trusted Enthusiast
SteveChandler
Posts: 2,257

The Boneheaded Code Thread

[ Edited ]

Sometimes there is a very clear cause to a problem but it is so obvious that I just don't see it. Sort of like looking all over the place for your glasses when they are on top of your head.

 

Let's put our boneheaded mistakes in this thread. Don't give away the problem and let others report how long it took to spot the issue with a fresh pair of eyes.

 

I have a large project with many classes and many queues. I spent an hour trying to debug an "issue" where one of my loops would keep iterating after a dequeue operation. I tried to find what was enqueuing to it by running the Desktop Execution Trace Toolkit. The strangest thing - DETT reported a single enqueue yet the loop kept initializing my device over and over again. I closed LabVIEW and rebooted. Same problem. I was just about to file a bug report (could it have to do with the large number of queues in my application?) when I spotted the problem.

 

How long does it take you to see the problem in this example which demonstrates the nature of the problem? It took me an hour - Doh! :smileyvery-happy: And my application has dozens of queues so it's not like I don't know how to use them.

 Doh!_BD.png

=====================
LabVIEW 2012


Active Participant
Andrey_Dmitriev
Posts: 1,536

Re: The Boneheaded Code Thread

Dequeue Element should be placed inside of while loop (I mean second loop). Isn't?

Trusted Enthusiast
SteveChandler
Posts: 2,257
0 Kudos

Re: The Boneheaded Code Thread

:smileyembarrassed: Yup. And I'll bet it just jumped right out at you too. What's the LabVIEW word for typo?

 

This one got me a long time ago.

 

Example_VI_BD.png

=====================
LabVIEW 2012


Trusted Enthusiast
Intaris
Posts: 3,184

Re: The Boneheaded Code Thread

The dequeue and the fact that you're sending "Init" instead of "Initialize" as a command string.....

Active Participant
drjdpowell
Posts: 253

Re: The Boneheaded Code Thread


Steve Chandler wrote:

How long does it take you to see the problem in this example which demonstrates the nature of the problem? 

 



15 seconds.  But knowing the problem is obvious means you look for the obvious.  I spent a large amount of time on a bug that was staring at me just recently.  I had a polymorphic VI that I removed one instance from, and LabVIEW automatically substituted another instance with the same connector pattern.  Obviously different icon, but I stared and stared at it and didn't notice.  The original VI was "Wait till this actor (loop) receives the shutdown message" and the replacement was "Send this actor the shutdowm message", which has a rather different effect.  I spent over an hour trying to track down who was sending the shutdown message to my actor before noticing.

Proven Zealot
Jeff·Þ·Bohrer
Posts: 7,816

Re: The Boneheaded Code Thread

I have to admit. it took me longer to swap between full and mobile than to spot the loop invariant init.
8-Ball Consulting advertising banner

Certified LabVIEW Consultant. The partner you can bank on when you're behind the 8-Ball.
Trusted Enthusiast
SteveChandler
Posts: 2,257
0 Kudos

Re: The Boneheaded Code Thread

[ Edited ]

Intaris wrote:

The dequeue and the fact that you're sending "Init" instead of "Initialize" as a command string.....


How ironic. I whipped up an example to show my "loop invariant init" and the example had another.... what's the word for typo in LabVIEW... :smileyfrustrated: (Although in this case it is in fact just a typo)

=====================
LabVIEW 2012


Proven Zealot
Jeff·Þ·Bohrer
Posts: 7,816
0 Kudos

Re: The Boneheaded Code Thread


Steve Chandler wrote:

Intaris wrote:

The dequeue and the fact that you're sending "Init" instead of "Initialize" as a command string.....


How ironic. I whipped up an example to show my "loop invariant init" and the example had another.... what's the word for typo in LabVIEW... :smileyfrustrated: (Although in this case it is in fact just a typo)


I had just assumed that was one of your space-saving strings---- go with that:smileywink:  That's your story- stick to it

8-Ball Consulting advertising banner

Certified LabVIEW Consultant. The partner you can bank on when you're behind the 8-Ball.
Proven Zealot
Jeff·Þ·Bohrer
Posts: 7,816

Re: The Boneheaded Code Thread

I wanted to come back and thatnk you for posting this.  I was a great opportunity to show around the shop!  EVERYONE now has show constant folding of wires ON, they know what the squiggly wires mean and they realize how useful that info can be.

Aside- I've had those squiggly lines on for so long that I usually know which wires will squiggle as I sling them- so when I look at other code ("Hey! Jeff! What's going on with my code?")  It looks funny without the constant wires squggled.  Guess what would have saved you an hour?

8-Ball Consulting advertising banner

Certified LabVIEW Consultant. The partner you can bank on when you're behind the 8-Ball.
Knight of NI
Knight of NI
Ben
Posts: 16,143

Re: The Boneheaded Code Thread

Oh boy!

 

A thread comparing boneheaded code developers. I think i can compete in that sandbox.

 

In this thread, Dennis helped me figure out why* I could not increment a control at run-time.

 

 

 

"I got better" since then.

 

Ben

 

*

 

Spoiler

Yes, it was disabled.

 

Ben Rayner
Who is NOT John Galt... yet... just building Rayner's Ridge
Scheduled to close on the new ridge next week!