Compatibility with Python 3.12 - Fatal Python error: PyGILState_Release: auto-releasing thread-state, but no thread-state for this thread
Hello, Fedora is rebuilding all Python packages with the upcoming Python 3.12. cffi is failing with 7th alpha. I'd like to ask for your help with this test's failures. Thank you.
OS: Fedora Rawhide x86_64 Python: 3.12.0a7 cffi: 1.15.1 full log: https://download.copr.fedorainfracloud.org/results/@python/python3.12/fedora-rawhide-x86_64/05901343-python-cffi/builder-live.log.gz
=================================== FAILURES ===================================
_____________________________ TestFFI.test_dlclose _____________________________
self = <cffi.api._make_ffi_library.<locals>.FFILibrary object at 0x7f008a810620>
> lambda self: read_variable(BType, name),
lambda self, value: write_variable(BType, name, value)))
E ValueError: library 'libm.so.6' has already been closed
cffi/api.py:848: ValueError
The above exception was the direct cause of the following exception:
self = <testing.cffi0.test_ffi_backend.TestFFI object at 0x7f008a544a40>
def test_dlclose(self):
if self.Backend is CTypesBackend:
pytest.skip("not with the ctypes backend")
ffi = FFI(backend=self.Backend())
ffi.cdef("int foobar(void); extern int foobaz;")
lib = ffi.dlopen(lib_m)
ffi.dlclose(lib)
e = pytest.raises(ValueError, getattr, lib, 'foobar')
assert str(e.value).startswith("library '")
assert str(e.value).endswith("' has already been closed")
> e = pytest.raises(ValueError, getattr, lib, 'foobaz')
testing/cffi0/test_function.py:540:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cffi/api.py:913: in __getattr__
return getattr(self, name)
cffi/api.py:912: in __getattr__
make_accessor(name)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
name = 'foobaz'
def make_accessor(name):
> with ffi._lock:
E SystemError: <built-in method __enter__ of _thread.lock object at 0x7f008a1cad00> returned a result with an exception set
cffi/api.py:901: SystemError
___________________ TestThread.test_first_calls_in_parallel ____________________
self = <testing.embedding.test_thread.TestThread object at 0x7f0087fcddf0>
def test_first_calls_in_parallel(self):
add1_cffi = self.prepare_module('add1')
self.compile('thread1-test', [add1_cffi], threads=True)
for i in range(20):
> output = self.execute('thread1-test')
testing/embedding/test_thread.py:9:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <testing.embedding.test_thread.TestThread object at 0x7f0087fcddf0>
name = 'thread1-test'
def execute(self, name):
path = self.get_path()
print('running %r in %r' % (name, path))
executable_name = name
if sys.platform == 'win32':
executable_name = os.path.join(path, executable_name + '.exe')
else:
executable_name = os.path.join('.', executable_name)
popen = self._run_base([executable_name], cwd=path,
stdout=subprocess.PIPE,
universal_newlines=True)
result = popen.stdout.read()
err = popen.wait()
if err:
> raise OSError("%r failed with exit code %r" % (
os.path.join(path, executable_name), err))
E OSError: '/tmp/ffi-0/embedding/test_first_calls_in_parallel/./thread1-test' failed with exit code -6
testing/embedding/test_basic.py:175: OSError
----------------------------- Captured stdout call -----------------------------
* setting env var 'LD_LIBRARY_PATH' to '/usr/bin:/tmp/ffi-0/embedding/test_first_calls_in_parallel'
compiling thread1-test with ['/tmp/ffi-0/embedding/test_basic/_add1_cffi.so']
running 'thread1-test' in '/tmp/ffi-0/embedding/test_first_calls_in_parallel'
RUNNING: ['./thread1-test'] {'cwd': '/tmp/ffi-0/embedding/test_first_calls_in_parallel', 'stdout': -1, 'universal_newlines': True}
----------------------------- Captured stderr call -----------------------------
Fatal Python error: PyGILState_Release: auto-releasing thread-state, but no thread-state for this thread
Python runtime state: initialized
Thread 0x00007fcdf59936c0 (most recent call first):
<no Python frame>
Thread 0x00007fcdf81986c0 (most recent call first):
<no Python frame>
Thread 0x00007fcdf79976c0 (most recent call first):
<no Python frame>
Thread 0x00007fcdf89996c0 (most recent call first):
<no Python frame>
Extension modules: _cffi_backend (total: 1)
____________________ TestThread.test_load_in_parallel_more _____________________
self = <testing.embedding.test_thread.TestThread object at 0x7f0087fcfb30>
def test_load_in_parallel_more(self):
add2_cffi = self.prepare_module('add2')
add3_cffi = self.prepare_module('add3')
self.compile('thread3-test', [add2_cffi, add3_cffi], threads=True)
for i in range(150):
> output = self.execute('thread3-test')
testing/embedding/test_thread.py:59:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <testing.embedding.test_thread.TestThread object at 0x7f0087fcfb30>
name = 'thread3-test'
def execute(self, name):
path = self.get_path()
print('running %r in %r' % (name, path))
executable_name = name
if sys.platform == 'win32':
executable_name = os.path.join(path, executable_name + '.exe')
else:
executable_name = os.path.join('.', executable_name)
popen = self._run_base([executable_name], cwd=path,
stdout=subprocess.PIPE,
universal_newlines=True)
result = popen.stdout.read()
err = popen.wait()
if err:
> raise OSError("%r failed with exit code %r" % (
os.path.join(path, executable_name), err))
E OSError: '/tmp/ffi-0/embedding/test_load_in_parallel_more/./thread3-test' failed with exit code -6
testing/embedding/test_basic.py:175: OSError
----------------------------- Captured stdout call -----------------------------
* setting env var 'LD_LIBRARY_PATH' to '/usr/bin:/tmp/ffi-0/embedding/test_load_in_parallel_more'
RUNNING: ['/usr/bin/python3', '/tmp/ffi-0/embedding/test_load_in_parallel_more/add3.py'] {'cwd': '/tmp/ffi-0/embedding/test_load_in_parallel_more', 'stdout': -1, 'universal_newlines': True}
generating ./_add3_cffi.c
the current directory is '/tmp/ffi-0/embedding/test_load_in_parallel_more'
FILENAME: /tmp/ffi-0/embedding/test_load_in_parallel_more/_add3_cffi.so
compiling thread3-test with ['/tmp/ffi-0/embedding/test_two_modules/_add2_cffi.so', '/tmp/ffi-0/embedding/test_load_in_parallel_more/_add3_cffi.so']
running 'thread3-test' in '/tmp/ffi-0/embedding/test_load_in_parallel_more'
RUNNING: ['./thread3-test'] {'cwd': '/tmp/ffi-0/embedding/test_load_in_parallel_more', 'stdout': -1, 'universal_newlines': True}
----------------------------- Captured stderr call -----------------------------
Fatal Python error: PyGILState_Release: auto-releasing thread-state, but no thread-state for this thread
Python runtime state: initialized
Thread 0x00007f6974ff96c0 (most recent call first):
<no Python frame>
Thread 0x00007f6976ffd6c0 (most recent call first):
<no Python frame>
Thread 0x00007f697e4636c0 (most recent call first):
<no Python frame>
Thread 0x00007f697d4616c0 (most recent call first):
<no Python frame>
Thread 0x00007f6977fff6c0 (most recent call first):
File "<init code for '_add3_cffi'>", line 7 in add3
Thread 0x00007f6973ff76c0 (most recent call first):
<no Python frame>
Thread 0x00007f6970ff16c0 (most recent call first):
File "<init code for '_add3_cffi'>", line 7 in add3
Thread 0x00007f6971ff36c0 (most recent call first):
<no Python frame>
Thread 0x00007f6972ff56c0 (most recent call first):
<no Python frame>
Thread 0x00007f69777fe6c0 (most recent call first):
File "<init code for '_add2_cffi'>", line 12 in add2
Thread 0x00007f697cc606c0 (most recent call first):
<no Python frame>
Thread 0x00007f69767fc6c0 (most recent call first):
<no Python frame>
Thread 0x00007f697dc626c0 (most recent call first):
<no Python frame>
Thread 0x00007f69717f26c0 (most recent call first):
<no Python frame>
Thread 0x00007f69757fa6c0 (most recent call first):
<no Python frame>
Thread 0x00007f69727f46c0 (most recent call first):
<no Python frame>
Thread 0x00007f69747f86c0 (most recent call first):
<no Python frame>
Thread 0x00007f69737f66c0 (most recent call first):
<no Python frame>
Thread 0x00007f697ec646c0 (most recent call first):
<no Python frame>
Extension modules: _cffi_backend (total: 1)
______________________ TestThreadLocal.test_thread_local _______________________
self = <testing.embedding.test_tlocal.TestThreadLocal object at 0x7f0087fcc710>
def test_thread_local(self):
tlocal_cffi = self.prepare_module('tlocal')
self.compile('tlocal-test', [tlocal_cffi], threads=True)
for i in range(10):
> output = self.execute('tlocal-test')
testing/embedding/test_tlocal.py:9:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <testing.embedding.test_tlocal.TestThreadLocal object at 0x7f0087fcc710>
name = 'tlocal-test'
def execute(self, name):
path = self.get_path()
print('running %r in %r' % (name, path))
executable_name = name
if sys.platform == 'win32':
executable_name = os.path.join(path, executable_name + '.exe')
else:
executable_name = os.path.join('.', executable_name)
popen = self._run_base([executable_name], cwd=path,
stdout=subprocess.PIPE,
universal_newlines=True)
result = popen.stdout.read()
err = popen.wait()
if err:
> raise OSError("%r failed with exit code %r" % (
os.path.join(path, executable_name), err))
E OSError: '/tmp/ffi-0/embedding/test_thread_local/./tlocal-test' failed with exit code -6
testing/embedding/test_basic.py:175: OSError
----------------------------- Captured stdout call -----------------------------
* setting env var 'LD_LIBRARY_PATH' to '/usr/bin:/tmp/ffi-0/embedding/test_thread_local'
RUNNING: ['/usr/bin/python3', '/tmp/ffi-0/embedding/test_thread_local/tlocal.py'] {'cwd': '/tmp/ffi-0/embedding/test_thread_local', 'stdout': -1, 'universal_newlines': True}
generating ./_tlocal_cffi.c
the current directory is '/tmp/ffi-0/embedding/test_thread_local'
FILENAME: /tmp/ffi-0/embedding/test_thread_local/_tlocal_cffi.so
compiling tlocal-test with ['/tmp/ffi-0/embedding/test_thread_local/_tlocal_cffi.so']
running 'tlocal-test' in '/tmp/ffi-0/embedding/test_thread_local'
RUNNING: ['./tlocal-test'] {'cwd': '/tmp/ffi-0/embedding/test_thread_local', 'stdout': -1, 'universal_newlines': True}
----------------------------- Captured stderr call -----------------------------
Fatal Python error: PyGILState_Release: auto-releasing thread-state, but no thread-state for this thread
Python runtime state: initialized
Thread 0x00007f71ea91c6c0 (most recent call first):
<no Python frame>
Thread 0x00007f71ea11b6c0 (most recent call first):
<no Python frame>
Thread 0x00007f71ec9206c0 (most recent call first):
<no Python frame>
Thread 0x00007f71ed1216c0 (most recent call first):
<no Python frame>
Extension modules: _cffi_backend (total: 1)
...
=========================== short test summary info ============================
FAILED testing/cffi0/test_ffi_backend.py::TestFFI::test_dlclose - SystemError...
FAILED testing/embedding/test_thread.py::TestThread::test_first_calls_in_parallel
FAILED testing/embedding/test_thread.py::TestThread::test_load_in_parallel_more
FAILED testing/embedding/test_tlocal.py::TestThreadLocal::test_thread_local
= 4 failed, 1939 passed, 96 skipped, 4 xfailed, 573 warnings in 251.82s (0:04:11) =