Kaydet (Commit) 108d1b4a authored tarafından Antoine Pitrou's avatar Antoine Pitrou

Issue #17703: Fix a regression where an illegal use of Py_DECREF() after…

Issue #17703: Fix a regression where an illegal use of Py_DECREF() after interpreter finalization can cause a crash.
üst 1b332065
...@@ -984,16 +984,22 @@ PyAPI_FUNC(void) _PyTrash_thread_destroy_chain(void); ...@@ -984,16 +984,22 @@ PyAPI_FUNC(void) _PyTrash_thread_destroy_chain(void);
#define PyTrash_UNWIND_LEVEL 50 #define PyTrash_UNWIND_LEVEL 50
/* Note the workaround for when the thread state is NULL (issue #17703) */
#define Py_TRASHCAN_SAFE_BEGIN(op) \ #define Py_TRASHCAN_SAFE_BEGIN(op) \
do { \ do { \
PyThreadState *_tstate = PyThreadState_GET(); \ PyThreadState *_tstate = PyThreadState_GET(); \
if (_tstate->trash_delete_nesting < PyTrash_UNWIND_LEVEL) { \ if (!_tstate || \
++_tstate->trash_delete_nesting; _tstate->trash_delete_nesting < PyTrash_UNWIND_LEVEL) { \
if (_tstate) \
++_tstate->trash_delete_nesting;
/* The body of the deallocator is here. */ /* The body of the deallocator is here. */
#define Py_TRASHCAN_SAFE_END(op) \ #define Py_TRASHCAN_SAFE_END(op) \
--_tstate->trash_delete_nesting; \ if (_tstate) { \
if (_tstate->trash_delete_later && _tstate->trash_delete_nesting <= 0) \ --_tstate->trash_delete_nesting; \
_PyTrash_thread_destroy_chain(); \ if (_tstate->trash_delete_later \
&& _tstate->trash_delete_nesting <= 0) \
_PyTrash_thread_destroy_chain(); \
} \
} \ } \
else \ else \
_PyTrash_thread_deposit_object((PyObject*)op); \ _PyTrash_thread_deposit_object((PyObject*)op); \
......
...@@ -17,6 +17,9 @@ Build ...@@ -17,6 +17,9 @@ Build
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #17703: Fix a regression where an illegal use of Py_DECREF() after
interpreter finalization can cause a crash.
- Issue #16447: Fixed potential segmentation fault when setting __name__ on a - Issue #16447: Fixed potential segmentation fault when setting __name__ on a
class. class.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment