Tuesday, August 01, 2006

Deadlock in the Python Lib

I spent most of today debugging a deadlock case in the Python Standard Library. I'm not sure if anyone's ever tried, but if you write a tracing function and pass it to threading.settrace, and within this function call 'threading.currentThread()', when the trace functions traces the thread code through threading.Thread.__delete, if will try to call threading.currentThread() *AFTER* _active[_get_ident()] has been deleted (threading.currentThread() just returns _active[_get_ident()]). Now the Python developers thought of the possibilty of asking for the currentThread() when it had been removed from _active, so they decided to create a _DummyThread object. Only this object tries to acquire a lock held in the threading.Thread.__delete method. *BOOM* deadlock.

Anywho, I'm tired, it's nearly 2am...

Comments: Post a Comment

Subscribe to Post Comments [Atom]





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]