Commit f11d5f4
cmdpy: prevent crash on
Summary:
Command flags like `--help` and `--version` go through a code path that
*partially* finalizes the Python runtime. They called `_PyRuntime_Finalize` [1]
but not `Py_Finalize`. There is no public API like `Py_IsInitialized` to detect
this situation and our `keepalive`'s `Py_Finalize` will crash like:
*** Signal 11 (SIGSEGV) (0x0) received by PID _ (code: address not mapped to object), stack trace: ***
...
PyThread_acquire_lock_timed
_PyUnicode_FromId
wait_for_thread_shutdown(_ts*)
Py_FinalizeEx
<cpython_ext::keepalive::PythonKeepAlive as core::ops::drop::Drop>::drop
eden/scm/lib/cpython-ext/src/keepalive.rs:108
commands::run::run_command
[1]: python/cpython@f5f336a
Fix it by explicitly skipping `Py_Finalize` before calling `Py_Main`.
Reviewed By: muirdm
Differential Revision: D75820513
fbshipit-source-id: e7f4478ed02ad9dd4ed96026f0a4e0488a6b9d36debugpython --help or --version
1 parent 1e33b1a commit f11d5f4
1 file changed
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
266 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
267 | 273 | | |
268 | 274 | | |
269 | 275 | | |
| |||
0 commit comments