[Python-Dev] test_threaded_import

Jack Jansen jack@oratrix.nl
Wed, 29 Aug 2001 22:16:43 +0200


Recently, "Tim Peters" <tim.one@home.com> said:
> Hmm!  You originally said this test hung "about 30% of the time", and didn't
> respond when I asked how you ran it.  Given the way you are running it, it
> should have hung 100% of the time.  So something here is still muddy.

Elementary, my dear Watson. I do a "make install", which runs the
regression tests twice, succeeding both times. Then I do "python" and
"import autotest", at which point it fails, thereby failing
approximately 30% of the time. Of course, not being Sherlock Jansen, I
didn't realise autotest!=regrtest for this:-)

> > or if you "import regrtest" in an interactive window,
> 
> Are you sure about that?  Works fine for me, and should work fine.

Sherlock Peters, you're absolutely right, of course:-)
The regrtest ran afoul of the small stack space for threads in
MacPython (for which I checked in a fix this afternoon). I didn't try
it again when that bug was fixed.

I'll apply your patch, which seems to fix the problem fine for the
time being. Still, there's three issues that I think need to be solved
at some point:
- the fact that you (or some other thread) are holding the import lock
  is one of the few Python state bits that are not open to
  introspection.
- There may be denial of service attacks possible with this if a 16
  year old scriptkiddy can think of a way to exploit it in a
  restricted interpreter.
- The whole idea that a process deadlocked on semaphore locks is
  completely uninterruptible also smells bad.
--
Jack Jansen             | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
www.cwi.nl/~jack        | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm