[solved] PyThread_acquire_lock freezes at pthread_cond_wait although lock not occupied

Gernot Hillier ghillie at suse.de
Fri Feb 28 14:39:51 CET 2003


Hi!

JFYI: I once reported a problem where one of my Python threads freezes at 
pthread_cond_wait in GNU/Linux although the Python lock is not occupied:

http://groups.google.com/groups?dq=&hl=de&lr=&ie=UTF-8&selm=b1tqqs%24q4e%241%40Fourier.suse.de

I've found the reason now: it was my fault: I created multiple threads as 
root and called os.setuid() in ONE thread only.

Now this thread has another UID than the others which isn't allowed in 
pthreads.

This leads to pthread_cond_signal not working because it uses kill() 
internally to weak up the other thread. But as a non-privileged thread 
can't kill() a root-thread, this failed. Unfortunately, there's no error 
checking for this case done in pthreads so it just silently looses the 
pthread_cond_signal event.

Just removing os.setuid() did the trick.

You're only allowed to setuid() a whole process including all threads...

Learned something the hard way :-}

-- 
Ciao,

Gernot




More information about the Python-list mailing list