Thursday, May 28, 2009

Cure Of The Notorious Ubuntu futex_wait Bug

It all started two months back, when DC++ suddenly stopped working on my Ubuntu 8.10 - the Intrepid Ibex. Each time I tried running it, it would hang : the Interface Window would turn gray and not respond. I'd have to use the Force Quit application or kill the process from the System Monitor list of processes. I tried reinstalling DC++, but it didn't solve the purpose. Soon other programs caught the infection and started exhibiting the same strange behaviour : Firefox, Gnome-do, EOG, python, and gvfs-fuse-daemon would hang at different times without issuing any warning. One day I noticed - in the Waiting Channel tab of the System Monitor - that they had a common waiting channel, “futex_wait”. I looked at the futex man page and learnt that futexes ( or better Fast Userspace muTexes ) were semaphores or mutex locks provided by Ubuntu to allow threads to work concurrently. The implications were clear : these multi-threaded applications were waiting on a futex and the duration of the wait indicated a deadlock.

The book “Operating System Principles” by Silberschatz, Galvin and Gagne says that in most Operating Systems, the method of handling deadlocks is to ignore deadlocks altogether and pretend that they never occur in the system. Further, it says that both Windows and UNIX use this solution. I researched a bit on the Internet and found that indeed it was a bug in the latest Ubuntu 2.6.27-* Kernels and the Ubuntu community was working on it to make sure the newer kernels don't fall prey to this problem.

I had learnt to live with the shortcoming until today when luckily I found a workaround for the problem. It turns out that switching off the "Assistive Technologies” does the trick.

Go to System > Preferences > Assistive Technologies
uncheck the "Enable Assistive Technologies" options.