[3.12] GH-108390: Prevent non-local events being set with sys.monitoring.set_local_events() (GH-108420) (#108899)

* GH-108390: Prevent non-local events being set with `sys.monitoring.set_local_events()` (GH-108420)

* Restore generated objects

* Restore size of monitoring arrays in code object for 3.12 ABI compatibility.

* Update ABI file
This commit is contained in:
Mark Shannon 2023-09-05 12:29:38 +01:00 committed by GitHub
parent 5121faabd1
commit 7ee021f999
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 3101 additions and 3001 deletions

View file

@ -8,16 +8,23 @@
extern "C" {
#endif
/* Count of all local monitoring events */
#define _PY_MONITORING_LOCAL_EVENTS 10
/* Count of all "real" monitoring events (not derived from other events) */
#define _PY_MONITORING_UNGROUPED_EVENTS 15
/* Count of all monitoring events */
#define _PY_MONITORING_EVENTS 17
/* Table of which tools are active for each monitored event. */
typedef struct _Py_Monitors {
/* Tables of which tools are active for each monitored event. */
/* For 3.12 ABI compatibility this is over sized */
typedef struct _Py_LocalMonitors {
/* Only _PY_MONITORING_LOCAL_EVENTS of these are used */
uint8_t tools[_PY_MONITORING_UNGROUPED_EVENTS];
} _Py_Monitors;
} _Py_LocalMonitors;
typedef struct _Py_GlobalMonitors {
uint8_t tools[_PY_MONITORING_UNGROUPED_EVENTS];
} _Py_GlobalMonitors;
/* Each instruction in a code object is a fixed-width value,
* currently 2 bytes: 1-byte opcode + 1-byte oparg. The EXTENDED_ARG
@ -81,9 +88,9 @@ typedef struct {
*/
typedef struct {
/* Monitoring specific to this code object */
_Py_Monitors local_monitors;
_Py_LocalMonitors local_monitors;
/* Monitoring that is active on this code object */
_Py_Monitors active_monitors;
_Py_LocalMonitors active_monitors;
/* The tools that are to be notified for events for the matching code unit */
uint8_t *tools;
/* Information to support line events */