Backwards Compatibility Means Bugs Too

Sometimes backwards compatibility means preserving bugs. When working on AMX Mod X 1.8.0, we found a very nasty bug in the code for creating new-menus.

For the unfamiliar, new-menus are a replacement for the original menu code (now dubbed “old-menus”). They were designed to be much simpler to use, though the basics are similar:

  • menu_create() binds a new-menu to a new-menu callback.
  • register_menucmd() binds an old-menu to an old-menu callback.

The two callbacks are very different: new-menu callbacks have three parameters (menu, client, item). Old-menu callbacks have two parameters (client, keypress). They are mutually exclusive.

Yet, there was a serious, accidental bug in AMX Mod X 1.7x — menu_create called register_menucmd on the same callback it used for its own callback. Effectively, your new-menu callback could receive random, invalid data because it was being invoked as an old-menu handler and a new-menu handler. This created almost untraceable and inexplicable bugs in a few plugins that had ventured into new-menu territory.

Needless to say, the code was removed very fast. Then when it came time to beta test 1.8.0, we received two reports that a specific plugin had stopped working. One of its menus was broken. After successfully reproducing the problem, I opened the plugin’s source code and found why.

The plugin was calling menu_create on callback X. However, it never called any of the other relevant new-menu functions. Instead, it used old-menus to actually draw and display the menu. Effectively, the author had replaced register_menucmd with menu_create. He probably intended to rewrite the rest of his code as well, but forgot. After all, his functionality continued to work as normal! So when AMX Mod X 1.8.0 removed this bug, his plugin broke.

Deciding whether to insert backward compatibility shims is always tough. Generally, we always want plugins to work on future versions, no matter what. There is a rough checklist I went through.

  • How many plugins are affected by the change? One.
  • How many people are affected by the change? 100-200. Punishing one author punishes all of these users.
  • How much code exists that is affected by the change? Unknown, assumed minimal.
  • Is the compatibility change a design decision, or a bug fix? How severe? Severe bug fix.
  • Is the break occurring from valid API usage or invalid API usage? If invalid, is it a mistake that is pervasive? Invalid usage localized to one line in one plugin.
  • Is backwards compatibility possible? No, the flaw is too severe to revert in any form.
  • Are any of the affected plugins no longer being maintained? No.

Given the above checklist, we decided to allow for this one plugin to receive reverted functionality. menu_create will call register_menucmd if and only if the plugin matches X and the plugin’s version matches Y. We notified the author saying, “if you release version Y+1, it will break on future AMX Mod X versions, so you will want to fix it.”

The conclusion: backwards compatibility sometimes means preserving bugs. Unfortunately, this gives new meaning to bugs being “undocumented features.” In the end, choosing whether to preserve bugs (or indeed any compatibility) depends on how many users you want to affect and how badly you want to affect them.

13 thoughts on “Backwards Compatibility Means Bugs Too

  1. sunil ramlall

    This was actually discussed a while ago and I was for it initially. Over time though it became apparent that the total community was getting involved with this project. Archiving this would be best for everyone.

    Reply
  2. peter taulli

    Great post! We’re a successful software design and development company specializing in creating e-commerce Websites, iPhone, Android, and windows 8 applications, facebook applications, Internet marketing (SEO/SEM/SMO and PPC campaigns)

    Reply
  3. Rocco Hartzfeld

    Con el tema de no tener frío en la parte del refrigerador, calculo que puede ser sensor, lo que no se es cuanto me tiene que medir en ohm. Tengo un combi FAGOR no-frost que en verano se dispara la alarma acústica a la más mínima. En segundo lugar, distinguir tu generosidad y gran persona que debes ser, ya que tomarte tanto tiempo para dedicar a ayudar a otros, habla por si solo. Hola, comparto con ustedes las experiencias que tenemos de ser sufridos pero contentos usuarios de una heladera NF General Electric TBG 16 ZBC desde el año 1995.

    Reply
  4. Ai Burritt

    I have recently started a website, the info you offer on this website has helped me tremendously. Thanks for all of your time & work. “Her grandmother, as she gets older, is not fading but rather becoming more concentrated.” by Paulette Bates Alden.

    Reply

Leave a Reply

Your email address will not be published.