]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
PyStats: Make sure that the `failure_kinds` array is big enough. (#133245)
authorMark Shannon <mark@hotpy.org>
Thu, 1 May 2025 10:02:51 +0000 (11:02 +0100)
committerGitHub <noreply@github.com>
Thu, 1 May 2025 10:02:51 +0000 (10:02 +0000)
Include/cpython/pystats.h
Python/specialize.c

index 7c1459bde8f1cfe5e48c8e91c240b795f70c8458..20eb969a9bac136816bc58ac6431a952adcf2877 100644 (file)
@@ -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
index 562e4a19d64a7f7069baeb118df3e2c6d004ff50..f4b06918e687873dc06a1f2e7bc080a2a9b4b272 100644 (file)
@@ -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)