Python 2.3.4c1 -- nasty threading bug (Linux)

Dieter Maurer dieter at handshake.de
Sun May 23 01:52:21 EDT 2004


"Tim Peters" <tim.one at comcast.net> writes on Fri, 21 May 2004 14:17:15 -0400:
> [Dieter Maurer]
> > Python apparently contains a long lasting threading bug on Linux
> > with LinuxThreads.
> ...
> > This problem causes multi-threaded applications such
> > as Zope to enter a funny state when one of the threads crashes.
> > Some of the threads die but others remain and can only be killed
> > with "kill -9". Normal restart logic fails for Zope because of these
> > remaining threads.
> >
> > <mailto:alangmead at boston.com> submitted a patch
> >
> > <http://sourceforge.net/tracker/index.php?func=detail&aid=949332&group_id=
> > 5470&atid=305470>
> > ...
> The patch wasn't applied, and the 2.3.4 release manager doesn't want to risk
> it for 2.3.4.  Do read the bug report!  There are 36 comments attached (so
> far) because it's a complex problem to solve it correctly.  Andrew Langmead
> (whose patch you referenced) is continuing to participate in finding a
> correct solution.  See his comment there dated 2004-05-04 10:00 for the
> relevant respect in which LinuxThreads is buggy but NPTL is not.

I verified that the patch mentioned above indeed fixes the problem.

It might introduce other subtle problems but at least none that
are revealed by Python's regression test suite...

Moreover, I doubt that such problems will be significant in practise:

  The patch prevents blocking of signals that should (as specified by the
  pthreads standard)
  not be blocked -- as the operating system uses these signals
  to report serious problems. No application should use
  these threads for application specific communication.

  Therefore, a violation of Python's principle to only
  deliver signals to the main thread seems appropriate
  for these signals.


It would be great, when the Python developers could come up with
an even better patch. However, those who run "productive"
multithreaded Python based applications, especially Zope 2,
on Linux with LinuxThreads (rather than native PosixThreads)
may consider to use the patch which is available *now*.

We will do so. I will report back should we see more serious
problems than we have now.

--
Dieter





More information about the Python-list mailing list