Closed as duplicate of#128639
Closed as duplicate of#128639
Description
Crash report
What happened?
I experimented a bit with concurrent.interpreters
using Python 3.14.0b4 (uv installed version). The code is both wrong in the usage, and contains a typo - the line mv[0] = 1
refers to an unbound variable. But it crashes with a "Fatal Python error" which I think is something that should not be possible even for buggy programs (correct me if I'm wrong).
import time
from concurrent import interpreters
def sub(mv: memoryview):
time.sleep(1)
print(mv[0])
def main():
buf = bytearray(1)
interp = interpreters.create()
t = interp.call_in_thread(sub, memoryview(buf))
mv[0] = 1
t.join()
main()
Output:
Traceback (most recent call last):
File "/home/ran/test.py", line 15, in <module>
main()
~~~~^^
File "/home/ran/test.py", line 12, in main
mv[0] = 1
^^
NameError: name 'mv' is not defined
Exception in thread Thread-1 (_call):
Exception: AttributeError: module '__main__' has no attribute 'sub'
The above exception was the direct cause of the following exception:
concurrent.interpreters.NotShareableError: object could not be unpickled
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/ran/.local/share/uv/python/cpython-3.14.0b4-linux-x86_64-gnu/lib/python3.14/threading.py", line 1081, in _bootstrap_inner
self._context.run(self.run)
~~~~~~~~~~~~~~~~~^^^^^^^^^^
File "/home/ran/.local/share/uv/python/cpython-3.14.0b4-linux-x86_64-gnu/lib/python3.14/threading.py", line 1023, in run
self._target(*self._args, **self._kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ran/.local/share/uv/python/cpython-3.14.0b4-linux-x86_64-gnu/lib/python3.14/concurrent/interpreters/__init__.py", line 215, in _call
res, excinfo = _interpreters.call(self._id, callable, args, kwargs, restrict=True)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
concurrent.interpreters.NotShareableError: func not shareable
Exception ignored while joining a thread in _thread._shutdown():
Traceback (most recent call last):
File "/home/ran/.local/share/uv/python/cpython-3.14.0b4-linux-x86_64-gnu/lib/python3.14/threading.py", line 1582, in _shutdown
_thread_shutdown()
PythonFinalizationError: cannot join thread at interpreter shutdown
Fatal Python error: Py_EndInterpreter: not the last thread
Python runtime state: finalizing (tstate=0x0000000001b40a48)
Current thread 0x00007f27ee43d780 [python3.14] (most recent call first):
<no Python frame>
Thread 0x00007f27ecd8b6c0 [Thread-1 (_call] (most recent call first):
File "/home/ran/.local/share/uv/python/cpython-3.14.0b4-linux-x86_64-gnu/lib/python3.14/concurrent/interpreters/__init__.py", line 215 in _call
File "/home/ran/.local/share/uv/python/cpython-3.14.0b4-linux-x86_64-gnu/lib/python3.14/threading.py", line 1023 in run
File "/home/ran/.local/share/uv/python/cpython-3.14.0b4-linux-x86_64-gnu/lib/python3.14/threading.py", line 1081 in _bootstrap_inner
File "/home/ran/.local/share/uv/python/cpython-3.14.0b4-linux-x86_64-gnu/lib/python3.14/threading.py", line 1043 in _bootstrap
Aborted (core dumped)
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.14.0b4 (main, Jul 8 2025, 21:00:06) [Clang 20.1.4 ]