All Articles

Lesson Learned from a Sad Story of Bumblebee

bug-bumblebee

When you fail to check a variable, it may cause a whole system failure? This sad story of the software Bumblebee will tell you: YES!

Bumblebee is an open source project, which names after the Bumblebee in Transformers. It’s a project aiming to support NVIDIA Optimus technology under Linux. It works on Optimus Laptops without a graphical multiplexer. Optimus comes from NVIDIA, it’s a technology that allows an integrated GPU and discrete NVIDIA GPU to be built into and accessed by a laptop.

It’s a memorable incident known as the “Bumblebee” commit this May. The essence of the story lies in the aftermath of the commit, where the user describes having written commit messages along the lines of “GIANT BUG… causing /usr to be deleted… so sorry…“. The root cause is a missing space character in the installation script, which leads to a rm -rf /usr command. What makes things worse, is that the bug lies in an installation shell script, which means in most cases, it’s executed by root.

The fix commit of this bug looks like,

diff --git a/install.sh b/install.sh
index 7d10ece..b1c571b 100755
--- a/install.sh
+++ b/install.sh
@@ -37,7 +37,7 @@
 #    You should have received a copy of the GNU General Public License
 #    along with bumblebee.  If not, see <http://www.gnu.org/licenses/>.
 #
-BUMBLEBEEVERSION=1.4.31
+BUMBLEBEEVERSION=1.4.32


 ROOT_UID=0
@@ -348,7 +348,7 @@ case "$DISTRO" in
   ln -s /usr/lib/mesa/ld.so.conf /etc/alternatives/gl_conf
   rm -rf /etc/alternatives/xorg_extra_modules
   rm -rf /etc/alternatives/xorg_extra_modules-bumblebee
-  rm -rf /usr /lib/nvidia-current/xorg/xorg
+  rm -rf /usr/lib/nvidia-current/xorg/xorg
   ln -s /usr/lib/nvidia-current/xorg /etc/alternatives/xorg_extra_modules-bumblebee
   ldconfig
  ;;

However, the most exciting thing is not this bug, but the code review comments about this bug from programmers around the world, which is really very joyful. Please watch closely!

The overall tone of the discussion reflects a mix of humor and understanding, with developers sharing their own experiences and lessons learned from unintentional file deletions. It emphasizes the importance of caution, code review, and adherence to best practices in software development to prevent potentially catastrophic mistakes.

Published Jun 21, 2011

Flying code monkey