Skip to content

Commit a4709e5

Browse files
GH-139193: Fix dump_stack when PYTHON_LLTRACE=4 (GH-139384)
1 parent e53e9eb commit a4709e5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Include/internal/pycore_stackref.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,12 @@ PyStackRef_IsError(_PyStackRef ref)
296296
return ref.bits == Py_TAG_INVALID;
297297
}
298298

299+
static inline bool
300+
PyStackRef_IsMalformed(_PyStackRef ref)
301+
{
302+
return (ref.bits & Py_TAG_BITS) == Py_TAG_INVALID;
303+
}
304+
299305
static inline bool
300306
PyStackRef_IsValid(_PyStackRef ref)
301307
{

Python/ceval.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ dump_item(_PyStackRef item)
160160
printf("<NULL>");
161161
return;
162162
}
163+
if (PyStackRef_IsMalformed(item)) {
164+
printf("<INVALID>");
165+
return;
166+
}
163167
if (PyStackRef_IsTaggedInt(item)) {
164168
printf("%" PRId64, (int64_t)PyStackRef_UntagInt(item));
165169
return;

0 commit comments

Comments
 (0)