STINNER Victor added the comment:

> I suggest thread_PyThread_start_new_thread() raise RuntimeError("can't start 
> thread: finalizing")

Where *exactly*? Py_FinalizeEx() first calls
wait_for_thread_shutdown() and *then* sets _Py_Finalizing to tstate.

Does wait_for_thread_shutdown() complete on this bug?

Note: It's not the first time that I noticed a deadlock around this
code :-/ I recall a silly bug when you press CTRL+c while
wait_for_thread_shutdown() is running.

See for example threading_shutdown_interrupted.py attached to the
issue #20526. Run it and quickly press CTRL+c. Sometime, it does crash
Python with a segfault...
---
haypo@selma$ ./python threading_shutdown_interrupted.py
..........................................................................................................................................................................................................Exception
ignored in: <module 'threading' from
'/home/haypo/prog/python/default/Lib/threading.py'>
Traceback (most recent call last):
  File "/home/haypo/prog/python/default/Lib/threading.py", line 1290,
in _shutdown
    t.join()
  File "/home/haypo/prog/python/default/Lib/threading.py", line 1056, in join
.    self._wait_for_tstate_lock()
  File "/home/haypo/prog/python/default/Lib/threading.py", line 1072,
in _wait_for_tstate_lock
...    elif lock.acquire(block, timeout):
  File "threading_shutdown_interrupted.py", line 29, in killer
..    raise KeyboardInterrupt()
KeyboardInterrupt:
^CSegmentation fault (core dumped)
---

Python finalization is a very fragile and complex task :-/

----------

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

Reply via email to