From 3831752689f4a43c26746b691c9c904550fadc17 Mon Sep 17 00:00:00 2001 From: Mark Shannon Date: Thu, 1 May 2025 11:02:51 +0100 Subject: PyStats: Make sure that the `failure_kinds` array is big enough. (#133245) --- Include/cpython/pystats.h | 2 +- Python/specialize.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Include/cpython/pystats.h b/Include/cpython/pystats.h index 7c1459b..20eb969 100644 --- a/Include/cpython/pystats.h +++ b/Include/cpython/pystats.h @@ -31,7 +31,7 @@ #define PYSTATS_MAX_UOP_ID 512 -#define SPECIALIZATION_FAILURE_KINDS 50 +#define SPECIALIZATION_FAILURE_KINDS 60 /* Stats for determining who is calling PyEval_EvalFrame */ #define EVAL_CALL_TOTAL 0 diff --git a/Python/specialize.c b/Python/specialize.c index 562e4a1..f4b0691 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -440,7 +440,9 @@ _Py_PrintSpecializationStats(int to_file) #define SPECIALIZATION_FAIL(opcode, kind) \ do { \ if (_Py_stats) { \ - _Py_stats->opcode_stats[opcode].specialization.failure_kinds[kind]++; \ + int _kind = (kind); \ + assert(_kind < SPECIALIZATION_FAILURE_KINDS); \ + _Py_stats->opcode_stats[opcode].specialization.failure_kinds[_kind]++; \ } \ } while (0) -- cgit v0.12