]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-139193: Fix dump_stack when PYTHON_LLTRACE=4 (GH-139384)
authorSergey Miryanov <sergey.miryanov@gmail.com>
Wed, 22 Oct 2025 13:14:25 +0000 (18:14 +0500)
committerGitHub <noreply@github.com>
Wed, 22 Oct 2025 13:14:25 +0000 (14:14 +0100)
Include/internal/pycore_stackref.h
Python/ceval.c

index 062834368bcd29cc43adb1c826262d703e45b0f0..efe9fb3b6c7c6aaa464c3abc5626d5caa21c66c5 100644 (file)
@@ -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)
 {
index f48f412fab83355ae1e6c2c13a3fbb342bdbb0cb..defd084db9a4bb4e8ad277654376944a2959a119 100644 (file)
@@ -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;