From: Sergey Miryanov Date: Wed, 22 Oct 2025 13:14:25 +0000 (+0500) Subject: GH-139193: Fix dump_stack when PYTHON_LLTRACE=4 (GH-139384) X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a4709e525f5bc3a1719b33f52377cccb2af70278;p=thirdparty%2FPython%2Fcpython.git GH-139193: Fix dump_stack when PYTHON_LLTRACE=4 (GH-139384) --- diff --git a/Include/internal/pycore_stackref.h b/Include/internal/pycore_stackref.h index 062834368bcd..efe9fb3b6c7c 100644 --- a/Include/internal/pycore_stackref.h +++ b/Include/internal/pycore_stackref.h @@ -296,6 +296,12 @@ PyStackRef_IsError(_PyStackRef ref) return ref.bits == Py_TAG_INVALID; } +static inline bool +PyStackRef_IsMalformed(_PyStackRef ref) +{ + return (ref.bits & Py_TAG_BITS) == Py_TAG_INVALID; +} + static inline bool PyStackRef_IsValid(_PyStackRef ref) { diff --git a/Python/ceval.c b/Python/ceval.c index f48f412fab83..defd084db9a4 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -160,6 +160,10 @@ dump_item(_PyStackRef item) printf(""); return; } + if (PyStackRef_IsMalformed(item)) { + printf(""); + return; + } if (PyStackRef_IsTaggedInt(item)) { printf("%" PRId64, (int64_t)PyStackRef_UntagInt(item)); return;