Arduino 0022 IDE Bug?? Bizarre!

I'm still troubleshooting, but maybe you can help...

Regarding s/w... I'm running Arduino 0022 on a Linux machine (Fedora 15). I have other options, as I'll describe later. My hardware is equivalent to an Arduino UNO (with the SMD chip), with optiboot bootloader - again, I have other versions too.

So I have a program... call it Sketch A. It compiles, loads, and runs without errors. I then make a simple change to a function outside of loop(), call it Sketch B. The change is literally commenting out a line:

BEFORE:
Serial.print("smoothData: average = ");

AFTER:
// Serial.print("smoothData: average = ");

After making this change, it still compiles and loads without errors. BUT the program does not seem to execute. The rotary knob and switches associated with the project have no effect.

I've seen two failure modes: 1) nothing at all is displayed in the serial monitor (it should), or 2) the first serial print command in loop() executes, and that's it. In either case, nothing at all happens afterwards.

If I UN-comment out the line above, the program runs fine. Bizarre!

I've tried running Arduino 0022 on Windows Vista... SAME ISSUE. I've tried an original Duemilanove (with original bootloader) AND different USB cable... SAME ISSUE.

I'm now suspecting the Arduino IDE or compiler. Has anyone run into this? Can you help?

Post your sketch.

Yes, I've had this happen to me. Actually several times. In EVERY single case it was caused by me indexing past the end of a buffer or something similar and blowing my stack. Most of the time it was a temporary variable that I ran past the end of and clobbered the stack so when I returned it went ricocheting off into never-never land.

My method of finding it is to comment out stuff, much like you did, then (on the screen) examining every stinking line until I find it.

I'm not much help am I? However, if the sketch is small enough, maybe someone here can help you spot it.

I'm now suspecting the Arduino IDE or compiler.

Don't. Really. The overwhelming liklihood is that the issue is in your code, either you've run out of RAM, or more likely here, as suggested, you're overflowing a buffer. Blaming the compiler just distracts you from what you should be doing, which is checking your code and possibly adding one of the implementations of freemem to see if you're short of RAM.

Of course, it is possible that you have found a bug in the compiler - it's bound to have some. If that's really the case and you can distill your code down to a small example that demonstrates it, the compiler maintainers would be glad to have it. However, Arduino programs are generally small and simple, and many many people have used the IDE and compiler without issue. Occam's Razor tells your therefore - it's your code. Which is good really, you can find it, fix it and move on. If it really were the compiler, you've hit a roadblock.

I have blamed various compilers for my issues a number of times - occasions I was correct? Zero.

Thanks a bunch for your input... Sure enough, I solved it by commenting out many of my "debug" Serial.print commands... I based this on your feedback, and on this post:

http://arduino.cc/forum/index.php/topic,72244.0.html

Again, I appreciate your help!

I have blamed various compilers for my issues a number of times - occasions I was correct? Zero.

That's been my batting average also. I've found that arguing with the compiler is like arguing with ones wife, even if your are right you are wrong, and lose out either way. :wink:

Lefty

=( Sadly that has not been my batting average. (About compilers, not the wife :D)

retrolefty:

I have blamed various compilers for my issues a number of times - occasions I was correct? Zero.

That's been my batting average also. I've found that arguing with the compiler is like arguing with ones wife, even if your are right you are wrong, and lose out either way. :wink:

I can recall exactly once when I found a compiler bug. The only ones I can think of hearing about recently were all over-optimization.

My wife had the displeasure of working with the MASCOMP C compiler. If it had to perform more than a few optimizations, it would give up and stop generating code. No warnings. No errors. And no machine code. It was impossible to tell the difference between a series bug and the compiler giving up.