Crash in ModuleType subclass with __slots__ #91047
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
assignee = 'https://github.com/markshannon' closed_at = <Date 2022-03-03.10:48:59.958> created_at = <Date 2022-03-01.21:25:06.644> labels = ['interpreter-core', 'release-blocker', 'type-crash', '3.11'] title = 'Crash in ModuleType subclass with __slots__' updated_at = <Date 2022-03-03.10:48:59.958> user = 'https://github.com/ronaldoussoren'
activity = <Date 2022-03-03.10:48:59.958> actor = 'Mark.Shannon' assignee = 'Mark.Shannon' closed = True closed_date = <Date 2022-03-03.10:48:59.958> closer = 'Mark.Shannon' components = ['Interpreter Core'] creation = <Date 2022-03-01.21:25:06.644> creator = 'ronaldoussoren' dependencies =  files =  hgrepos =  issue_num = 46891 keywords = ['patch', '3.11regression'] message_count = 10.0 messages = ['414294', '414296', '414300', '414304', '414322', '414356', '414357', '414360', '414368', '414418'] nosy_count = 4.0 nosy_names = ['ronaldoussoren', 'Mark.Shannon', 'pablogsal', 'Dennis Sweeney'] pr_nums = ['31643'] priority = 'release blocker' resolution = 'fixed' stage = 'resolved' status = 'closed' superseder = None type = 'crash' url = 'https://bugs.python.org/issue46891' versions = ['Python 3.11']
The text was updated successfully, but these errors were encountered:
The following crashes the interpreter in Python 3.11, and works fine in older versions:
# --- script.py import types class MyModule (types.ModuleType): __slots__ = ( "_MyModule__a", "_MyModule__b", ) def __init__(self, name): super().__init__(name) m = MyModule("name") # -- end of file
The key in this is the
This is a reproducer based on code in PyObjC.
The crash itself happens during garbage collection:
% python3.11 -Xdev t.py (master)pyobjc-8
Current thread 0x0000000104ce0580 (most recent call first):
And when using a debug build and -Xdev:
../Modules/gcmodule.c:2187: visit_validate: Assertion failed: PyObject_GC_Track() object is not valid
object address : 0x101a5f690
Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailed
Current thread 0x00000001019c0580 (most recent call first):
The debug build seems to indicate that slot memory is not initiated properly, a stack trace (note the argument to visit_validate at frame #7):