diff options
author | Campbell Barton <campbell@blender.org> | 2022-08-19 09:20:20 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-08-19 09:23:29 +0300 |
commit | 5c9bea25d08ccdcac004d22046d0ca08ad3f462c (patch) | |
tree | d19add25318b5c9592f80cb3022cb818fbc61f55 /source | |
parent | 529f0427fce2245d60eb885518f055209405b016 (diff) |
Fix crash accessing PyEval_GetFrame from Python's crash handler
Check the thread-state before accessing PyEval_GetFrame, since this is
a crash handler, the state of the Python interpreter isn't known.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 939fa475344..23fc0bcaeda 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -585,6 +585,11 @@ void BPY_python_use_system_env(void) void BPY_python_backtrace(FILE *fp) { fputs("\n# Python backtrace\n", fp); + + /* Can happen in rare cases. */ + if (!_PyThreadState_UncheckedGet()) { + return; + } PyFrameObject *frame; if (!(frame = PyEval_GetFrame())) { return; |