python + build ports = failure (threading problem)

David Naylor naylor.b.david at gmail.com
Wed Nov 10 21:51:03 UTC 2010


Hi,

I've found a problem in FreeBSD's implementation for threads, pth does not 
have this problem.  

The following test case consistantly reproduces the problem:

--- start ---

#! /usr/bin/env python
from subprocess import Popen, PIPE
from threading import Lock, Thread

def runner():
  process = Popen(("make", "-C", "/usr/ports/graphics/kdegraphics4", "clean", 
"all"), close_fds=True)
  process.wait()

# If runner called directly then port compiles correctly, otherwise it stalls
Thread(target=runner).start()

--- end ---

The port stalls with 
<snip/>
grep: writing output: Broken pipe
grep: writing output: Broken pipe
grep: writing output: Broken pipe
 - found
===>  Configuring for kdegraphics-4.5.3
/bin/mkdir -p /usr/ports/graphics/kdegraphics4/work/kdegraphics-4.5.3/build
<end/>

The grep errors appear to be mostly harmless, `ps` shows:
<snip/>
17648   4  D      0:00.03 python test.py
17649   4  D      0:00.08 make -C /usr/ports/graphics/kdegraphics4 clean all
17974   4  D      0:00.03 [cmake]
17978   4  Z      0:00.03 <defunct>
<snip/>

I suspect any port using cmake will have this problem (unconfirmed) and if 
memory serves me correct then building lang/perl causes the same problem 
(although the stall happens much later on in the build).  

Using WITH_PTH when building python fixes the problem so I suspect libthr as 
the cause of the problem.  

I hope someone finds this information useful.  

David

P.S. Should a PR be filed for this?
P.S.S. It is possible that one of pythons test cases can reproduce this...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: This is a digitally signed message part.
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20101110/2301dfba/attachment.pgp


More information about the freebsd-hackers mailing list