Skip to content

Commit 3831752

Browse files
authored
PyStats: Make sure that the failure_kinds array is big enough. (#133245)
1 parent fe3c7e1 commit 3831752

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Include/cpython/pystats.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#define PYSTATS_MAX_UOP_ID 512
3333

34-
#define SPECIALIZATION_FAILURE_KINDS 50
34+
#define SPECIALIZATION_FAILURE_KINDS 60
3535

3636
/* Stats for determining who is calling PyEval_EvalFrame */
3737
#define EVAL_CALL_TOTAL 0

Python/specialize.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,9 @@ _Py_PrintSpecializationStats(int to_file)
440440
#define SPECIALIZATION_FAIL(opcode, kind) \
441441
do { \
442442
if (_Py_stats) { \
443-
_Py_stats->opcode_stats[opcode].specialization.failure_kinds[kind]++; \
443+
int _kind = (kind); \
444+
assert(_kind < SPECIALIZATION_FAILURE_KINDS); \
445+
_Py_stats->opcode_stats[opcode].specialization.failure_kinds[_kind]++; \
444446
} \
445447
} while (0)
446448

0 commit comments

Comments
 (0)