New submission from Daniel Stutzbach <dan...@stutzbachenterprises.com>:

"some_set in some_set_of_sets" contains a race condition that can lead to odd 
behavior.  To perform the test, the set_contains() function in setobject.c 
creates a temporary frozenset object (t), swaps the bodies of some_set and t, 
checks if t is in some_set_of_sets, then swaps the bodies back.

Unfortunately, comparisons or hash functions may release the GIL, so the 
swapped bodies may be exposed on a different thread, i.e., "some_set in 
some_set_of_sets" may cause "some_set" to be empty on some other thread.

The same race condition exists in set_discard() and set_remove().

Attached is a short script that demonstrates the problem and could be easily 
converted to a unit test.

----------
components: Interpreter Core
files: set-race.py
messages: 106007
nosy: stutzbach
priority: normal
severity: normal
status: open
title: Race condition when checking for set in set
type: behavior
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2
Added file: http://bugs.python.org/file17388/set-race.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8757>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to