INADA Naoki added the comment: This script can cause deadlock on Python 3.6.
1. Other threads can register traceback to sys module after sys module dict is cleaned up. 2. In Py_Finalize, __del__ method of arbitrary object in the traceback can be called. 3. The __del__ method calls threading.Thread.start() 4. Thread.start() waits self.__started event which is set by Thread.__bootstrap 5. While finalizing, threads other than main thread exits when getting GIL. So Thread.__bootstrap() won't be called. 6. Thread.start() in main thread waits self.__started event forever. I suggest thread_PyThread_start_new_thread() raise RuntimeError("can't start thread: finalizing") ---------- Added file: http://bugs.python.org/file45643/finish-deadlock.py _______________________________________ 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