This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Python 2.4.1 locking bug test case simplified!

$ python
each test group is testing 1000 items
sem_init: Resource temporarily unavailable
Exception in thread Thread-4:
Traceback (most recent call last):
  File "/tmp/python.572/usr/lib/python2.4/", line 442, in
  File "/tmp/python.572/usr/lib/python2.4/", line 422, in run
    self.__target(*self.__args, **self.__kwargs)
  File "", line 10, in reader
    msg = Q.get()
  File "/tmp/python.572/usr/lib/python2.4/", line 119, in get
  File "/tmp/python.572/usr/lib/python2.4/", line 197, in wait
    waiter = _allocate_lock()
error: can't allocate lock

<process has to be killed from the Windows Task Manager, keyboard kill commands are ineffective.> is:
from Queue import Queue
from threading import Thread

def writer( Q, values ):
    for i in values:
        Q.put( i )

def reader( Q, values ):
    for i in values:
        msg = Q.get()
        assert msg == i

def test_session( Qsize, msgs ):
    q1 = Queue( Qsize )
    w = Thread( target=writer, args=( q1, msgs ) )
    r = Thread( target=reader, args=( q1, msgs ) )

msgs = range(1000)
print "each test group is testing %d items" % len( msgs )

test_session( 2, msgs )
test_session( 2, msgs )

cygcheck.out is attached.

I had to play with the number of items being queued/enqueued in order to get the bug to reliably happen on my machine.

The queue size, number of threads, and number of items being processed all affect whether or not this bug will manifest itself, which leads me to believe that the bug is a threading-timing issue that is probably highly specific to how Python is handling threads and locking resources. But that is just a guess, of course.

Since all my attempts to simplify it further also fail to reproduce the bug, I think it is time to build my own debugging version of Python and see what I can learn from the inside, but that won't happen (vacations, etc.) for a few weeks.


Attachment: cygcheck.out
Description: Binary data

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]