From fcf7a5f05f9f42840be35baef843498225fcace5 Mon Sep 17 00:00:00 2001 From: lipengyu Date: Wed, 17 Jun 2026 14:33:56 +0800 Subject: [PATCH 1/2] Fix cross-interpreter NotShareableError ref handling --- Python/crossinterp_data_lookup.h | 1 + Python/crossinterp_exceptions.h | 1 + 2 files changed, 2 insertions(+) diff --git a/Python/crossinterp_data_lookup.h b/Python/crossinterp_data_lookup.h index 54422ad2335cb62..62fe3ff44660b79 100644 --- a/Python/crossinterp_data_lookup.h +++ b/Python/crossinterp_data_lookup.h @@ -100,6 +100,7 @@ _PyXI_UnwrapNotShareableError(PyThreadState * tstate, _PyXI_failure *failure) if (failure != NULL) { _PyXI_errcode code = _PyXI_ERR_NOT_SHAREABLE; if (_PyXI_InitFailure(failure, code, exc) < 0) { + Py_DECREF(exc); return -1; } } diff --git a/Python/crossinterp_exceptions.h b/Python/crossinterp_exceptions.h index 98411adc5eb3f6f..0d144ffdaf4f5b5 100644 --- a/Python/crossinterp_exceptions.h +++ b/Python/crossinterp_exceptions.h @@ -83,6 +83,7 @@ _ensure_notshareableerror(PyThreadState *tstate, // A NotShareableError instance is already set. assert(cause == NULL); _PyErr_SetRaisedException(tstate, ctx); + return; } } else { From 8c1af7456314be4cc494045adbc379bf915c2e3d Mon Sep 17 00:00:00 2001 From: lipengyu Date: Fri, 24 Jul 2026 09:42:48 +0800 Subject: [PATCH 2/2] gh-151578: Add NotShareableError NEWS entry --- .../2026-07-24-09-42-24.gh-issue-151578.JNkQoM.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2026-07-24-09-42-24.gh-issue-151578.JNkQoM.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-24-09-42-24.gh-issue-151578.JNkQoM.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-07-24-09-42-24.gh-issue-151578.JNkQoM.rst new file mode 100644 index 000000000000000..db758c4d2c21d2e --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-07-24-09-42-24.gh-issue-151578.JNkQoM.rst @@ -0,0 +1,2 @@ +Fix potential use-after-free and reference leaks in cross-interpreter +``NotShareableError`` error handling.