https://github.com/python/cpython/commit/a4709e525f5bc3a1719b33f52377cccb2af70278
commit: a4709e525f5bc3a1719b33f52377cccb2af70278
branch: main
author: Sergey Miryanov <[email protected]>
committer: markshannon <[email protected]>
date: 2025-10-22T14:14:25+01:00
summary:

GH-139193: Fix dump_stack when PYTHON_LLTRACE=4 (GH-139384)

files:
M Include/internal/pycore_stackref.h
M Python/ceval.c

diff --git a/Include/internal/pycore_stackref.h 
b/Include/internal/pycore_stackref.h
index 062834368bcd29..efe9fb3b6c7c6a 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 f48f412fab8335..defd084db9a4bb 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -160,6 +160,10 @@ dump_item(_PyStackRef item)
         printf("<NULL>");
         return;
     }
+    if (PyStackRef_IsMalformed(item)) {
+        printf("<INVALID>");
+        return;
+    }
     if (PyStackRef_IsTaggedInt(item)) {
         printf("%" PRId64, (int64_t)PyStackRef_UntagInt(item));
         return;

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to