Thursday, June 01, 2006

Unexpected Deadlocks!

Yesterday, I spent the whole afternoon trying to fix a bug in EditION application. After a few hours of despair, I finally found the source of the problem. Its was caused by an unexpected deadlock of the working threads. Despite all my efforts of avoid such situations when programming threads, I relentlessly inserted mutex lockers inside class destructors. This was a very bad idea. Usually, a destructor calls other destructors. This way, an unexpected deadlock can easily happen.

Thus, yesterday I learned an important lesson: Thread synchronization in destructors should be used very carefully.

No comments: