This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients eric.smith, irmen, methane, pwp333, vstinner
Date 2016-11-25.14:25:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAMpsgwZdrQFe0RgwV+73v5Oavh45jraEpaBbuCHUSm275D3trQ@mail.gmail.com>
In-reply-to <1480081154.73.0.735827907914.issue28673@psf.upfronthosting.co.za>
Content
> 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 :-/
History
Date User Action Args
2016-11-25 14:25:22vstinnersetrecipients: + vstinner, irmen, eric.smith, methane, pwp333
2016-11-25 14:25:22vstinnerlinkissue28673 messages
2016-11-25 14:25:21vstinnercreate