This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mschmitzer
Recipients mschmitzer
Date 2015-01-08.13:02:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1420722137.58.0.63717437035.issue23191@psf.upfronthosting.co.za>
In-reply-to
Content
The way the fnmatch module uses its regex cache is not threadsafe. When multiple threads use the module in parallel, a race condition between retrieving a - presumed present - item from the cache and clearing the cache (because the maximum size has been reached) can lead to KeyError being raised.

The attached script demonstrates the problem. Running it will (eventually) yield errors like the following.

Exception in thread Thread-10:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "fnmatch_thread.py", line 12, in run
    fnmatch.fnmatchcase(name, pat)
  File "/home/marc/.venv/modern/lib/python2.7/fnmatch.py", line 79, in fnmatchcase
    return _cache[pat].match(name) is not None
KeyError: 'lYwrOCJtLU'
History
Date User Action Args
2015-01-08 13:02:17mschmitzersetrecipients: + mschmitzer
2015-01-08 13:02:17mschmitzersetmessageid: <1420722137.58.0.63717437035.issue23191@psf.upfronthosting.co.za>
2015-01-08 13:02:17mschmitzerlinkissue23191 messages
2015-01-08 13:02:17mschmitzercreate