[New-bugs-announce] [issue45691] Partial moving of core objects to interpreter state is incorrect at best, unsafe at worse.

Mark Shannon report at bugs.python.org
Tue Nov 2 12:04:49 EDT 2021


New submission from Mark Shannon <mark at hotpy.org>:

We currently have an unstable state in the VM where some core objects are static and some are per-interpreter.

For example, smalls ints are allocated per-interpreter, but many classes are allocated statically.
This means that if any int is reachable from a class, then references to per-interpreter objects can be left dangling, or be out of date.

E.g. consider this sequence:
1. Create an interpreter
2. Destroy it.
3. Create a new interpreter

`sys.float_info.n_unnamed_fields` causes a memory violation if the per-interpreter allocated 0 held by sys.float_info.n_unnamed_fields is freed.
If it is not freed, then `sys.float_info.n_unnamed_fields is 0` is False, meaning that there are two zeros present.

The above is just an example. Classes have many references to ints, floats, code  objects, etc. Any of those could have the same issue.

All objects that form the core object graph must either be entirely static, or entirely per-interpreter.

We cannot change from static to per-interpreter in a piecemeal fashion. It must be done all at once.

----------
components: Interpreter Core
messages: 405514
nosy: Mark.Shannon, eric.snow, vstinner
priority: normal
severity: normal
status: open
title: Partial moving of core objects to interpreter state is incorrect at best, unsafe at worse.
type: behavior
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45691>
_______________________________________


More information about the New-bugs-announce mailing list