Tuesday, February 8, 2011

Three Stooges Syndrome

True Story: Coworker and I recently found a bug where three programmers who no longer work with us had touched the code in the rendering loop and introduced three separate quite serious bugs.

The result was a “Mr Burns” bug where the bugs were acting symbiotically together to produce almost acceptable behavior and not crash. Fixing one or two (but not all three) bugs would result in catastrophic failure since any remaining bug would cause fatal behavior. However, leaving all three bugs in the code together allowed it to survive and limp along without crashing but with suboptimal results under certain conditions.

The only way to fix any of the bugs without causing issues was to fix all three simultaneously - which is what I did but only after a couple serious WTF's.

Rarely have I ever seen such an outstanding collaboration of obviously wrong code somehow cobbled together to produce a result that seems to work under many conditions even though it’s obvious that serious coding errors were present and demonstratably exhibiting buggy behavior while the code was “working”… it was truly a bad code masterpiece.