October 21, 2010
Conditional breakpoints can cause side-effects.
I had the strangest bug the other day. One part of code just suddenly stopped working, a variable was being set to the wrong value somehow but I could not find where it was being set. I reverted back to a working copy from source control, chalking it up to one of those random mysteries. Still not working. Rebooted, did a clean checkout. Still nothing. At this point I was very frustrated. I removed a breakpoint and it suddenly started working again. It was the strangest thing.
Then I realized what happened. I had set a conditional breakpoint, but instead of setting to condition to “foo == bar” I had set it to “foo = bar” so it was assigning the value. Doh!
Judah Gabriel Himango said,
October 24, 2010 at 2:01 am
Ouch.
Had one recently where, after looking at an object in the debugger, the object’s internal state became whacky.
Took me a while to figure out that the author of the object had a property getter that actually set the value of some other property, e.g. the getter for Foo was setting Bar then returning Foo.
Side-effects inside property getters = pure evil.