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 colesbury
Recipients colesbury, gregory.p.smith, izbyshev, jbms, pitrou, vstinner
Date 2021-11-15.22:28:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1637015339.12.0.423768637375.issue42969@roundup.psfhosted.org>
In-reply-to
Content
The `pthread_exit` behavior has been a problem for PyTorch and related libraries since Python 3.9. The PyTorch team has tried working around the problems without success (i.e. they keep getting bug reports involving crashes in PyEval_SaveThread/RestoreThread).

The hang/paused the thread behavior suggested by jbms and gps seems like the only reliable option. This is also what the Java VM does when returning from native code and the JVM has exited.

I believe it's not difficult to hang a thread in a cross-platform way: create a mutex, acquire it in the main thread (before setting PyRuntime._finalizing), never release it. Other threads can acquire that same mutex to block until the application exits.

The crashes can occur even without daemon threads if the user presses ctrl-c while _thread_shutdown is running.
History
Date User Action Args
2021-11-15 22:28:59colesburysetrecipients: + colesbury, gregory.p.smith, pitrou, vstinner, izbyshev, jbms
2021-11-15 22:28:59colesburysetmessageid: <1637015339.12.0.423768637375.issue42969@roundup.psfhosted.org>
2021-11-15 22:28:59colesburylinkissue42969 messages
2021-11-15 22:28:58colesburycreate