[Python-bugs-list] [ python-Bugs-544473 ] Queue module can deadlock
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 17 Apr 2002 22:09:43 -0700
Bugs item #544473, was opened at 2002-04-15 22:09
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=544473&group_id=5470
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Mark Hammond (mhammond)
Assigned to: Mark Hammond (mhammond)
Summary: Queue module can deadlock
Initial Comment:
Prompted by a users experimentation where he was able
to show Pythonwin hanging, I have found a case where
the Queue module deadlocks. It appears that if a
RuntimeError is generated while queueing data, the
queue lock will remain held.
Attaching a test script. This hangs on Win2k and
Linux. Win2k callstack shows Queue is waiting for the
following lock (line 53)
if block:
self.fsema.acquire()
Presumably (but untested at the moment), the previous
call to q.put(), which triggered a "RuntimeError:
maximum recursion depth exceeded", left the lock acquired.
It seems a few choice try/finally statements in the
Queue module would go along way :) I will try and get
to this soon.
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2002-04-18 01:09
Message:
Logged In: YES
user_id=31435
The patch looks good to me, but I would like to see a test
case. Note that you can build a reliable test case by
subclassing Queue and overriding its _put and/or _get
methods, arranging to raise an exception deliberately from
them. Any exception in these would leave a semaphore and
self.mutex held forever in the current Queue.py.
----------------------------------------------------------------------
Comment By: Mark Hammond (mhammond)
Date: 2002-04-16 08:18
Message:
Logged In: YES
user_id=14198
This patch seems reasonable to me. Tim, a quick look would
be appreciated. Writing a reasonable test case seems
difficult :( It doesn't seem worth adding this little test
script to the test suite.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2002-04-15 22:47
Message:
Logged In: YES
user_id=31435
Yup, it hangs on Win98 too. Nice job of whittling it down,
Mark! We've been looking for an excuse to make Queue
slower too <wink>.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=544473&group_id=5470