The test_concurrency() of test_import fails randomly on sys.settrace(). Example:
$ ./python -m test test_import -m test_concurrency -v -j30 -F --fail-env-changed
(...)
0:00:13 load avg: 12.46 [ 97/1] test_import failed (env changed)
test_concurrency (test.test_import.ImportTests) ... ok
----------------------------------------------------------------------
Ran 1 test in 0.487s
OK
Warning -- Uncaught thread exception: RuntimeError
Exception in thread Thread-13 (run):
Traceback (most recent call last):
File "/home/vstinner/python/3.10/Lib/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/home/vstinner/python/3.10/Lib/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/home/vstinner/python/3.10/Lib/test/test_import/__init__.py", line 457, in run
sys.settrace(None)
RuntimeError: Cannot install a trace function while another trace function is being installed
(...)
The problem is that the _PyEval_SetTrace() function fails with RuntimeError("Cannot install a trace function while another trace function is being installed") on Py_XDECREF(traceobj); indirectly calls sys.settrace().
IMO Py_XDECREF(traceobj); should be called afterreentrant = 0;, at the end of the function.
The text was updated successfully, but these errors were encountered:
Make sys.setprofile() and sys.settrace() functions reentrant. They
can no long fail with: RuntimeError("Cannot install a trace function
while another trace function is being installed").
Make _PyEval_SetTrace() and _PyEval_SetProfile() functions reentrant,
rather than detecting and rejecting reentrant calls. Only delete the
reference to function arguments once the new function is fully set,
when a reentrant call is safe. Call also _PySys_Audit() earlier.
vstinner commentedOct 14, 2022
The test_concurrency() of test_import fails randomly on sys.settrace(). Example:
The problem is that the _PyEval_SetTrace() function fails with RuntimeError("Cannot install a trace function while another trace function is being installed") on
Py_XDECREF(traceobj);
indirectly callssys.settrace()
.IMO
Py_XDECREF(traceobj);
should be called afterreentrant = 0;
, at the end of the function.The text was updated successfully, but these errors were encountered: