From a4709e525f5bc3a1719b33f52377cccb2af70278 Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Wed, 22 Oct 2025 18:14:25 +0500 Subject: [PATCH] GH-139193: Fix dump_stack when PYTHON_LLTRACE=4 (GH-139384) --- Include/internal/pycore_stackref.h | 6 ++++++ Python/ceval.c | 4 ++++ 2 files changed, 10 insertions(+) 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; -- 2.47.3