Commit d51bcd7e authored by Kirill Smelkov's avatar Kirill Smelkov

libgolang/thread: Upstream PyThread_release_lock bug should have been fixed

Race condition inside PyThread_release_lock should have been fixed on
both CPython/darwin and PyPy/darwin:

    https://github.com/python/cpython/commit/c5abd63e94fc
    https://bitbucket.org/pypy/pypy/commits/6cd7a0d1a940
    https://bitbucket.org/pypy/pypy/commits/a9d36d6af872

The bug is explained here:

    https://bugs.python.org/issue38106
    https://bitbucket.org/pypy/pypy/issues/3072

The following commits added tests for the bug on Pygolang side:

    34b7a1f4 (golang: Expose Sema and Mutex as public Python and Cython/nogil API)
    5142460d (libgolang/thread: Add links to upstream PyThread_release_lock bug)
parent 0efd4a9a
...@@ -35,7 +35,7 @@ from __future__ import print_function, absolute_import ...@@ -35,7 +35,7 @@ from __future__ import print_function, absolute_import
from cpython.pythread cimport PyThread_acquire_lock, PyThread_release_lock, \ from cpython.pythread cimport PyThread_acquire_lock, PyThread_release_lock, \
PyThread_type_lock, WAIT_LOCK PyThread_type_lock, WAIT_LOCK
# FIXME On Darwin, even though this is considered as POSIX, Python uses # NOTE On Darwin, even though this is considered as POSIX, Python uses
# mutex+condition variable to implement its lock, and, as of 20190828, Py2.7 # mutex+condition variable to implement its lock, and, as of 20190828, Py2.7
# implementation, even though similar issue was fixed for Py3 in 2012, contains # implementation, even though similar issue was fixed for Py3 in 2012, contains
# synchronization bug: the condition is signalled after mutex unlock while the # synchronization bug: the condition is signalled after mutex unlock while the
...@@ -57,18 +57,17 @@ from cpython.pythread cimport PyThread_acquire_lock, PyThread_release_lock, \ ...@@ -57,18 +57,17 @@ from cpython.pythread cimport PyThread_acquire_lock, PyThread_release_lock, \
# - https://bugs.python.org/issue38106 # - https://bugs.python.org/issue38106
# - https://bitbucket.org/pypy/pypy/issues/3072 # - https://bitbucket.org/pypy/pypy/issues/3072
# #
# -> TODO maintain our own semaphore code or stop printing the warning when/if # and fixed in CPython 2.7.17 and PyPy 7.2 .
# fixed CPython/PyPy versions are released.
import sys, platform import sys, platform
if 'darwin' in sys.platform: if 'darwin' in sys.platform:
pyimpl = platform.python_implementation() pyimpl = platform.python_implementation()
pyver = sys.version_info pyver = sys.version_info
buggy = buglink = None buggy = buglink = None
if 'CPython' in pyimpl and pyver < (3, 0): if 'CPython' in pyimpl and pyver < (3, 0) and pyver < (2,7,17):
buggy = "cpython2/darwin" buggy = "cpython2/darwin < 2.7.17"
buglink = "https://bugs.python.org/issue38106" buglink = "https://bugs.python.org/issue38106"
if 'PyPy' in pyimpl: if 'PyPy' in pyimpl and sys.pypy_version_info < (7,2):
buggy = "pypy/darwin" buggy = "pypy/darwin < 7.2"
buglink = "https://bitbucket.org/pypy/pypy/issues/3072" buglink = "https://bitbucket.org/pypy/pypy/issues/3072"
if buggy: if buggy:
print("WARNING: pyxgo: thread: %s has race condition bug in runtime" print("WARNING: pyxgo: thread: %s has race condition bug in runtime"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment