Skip to content

Overflow when computing __sizeof__ of objects with underlying code objects #126119

Open
@federicovalenso

Description

@federicovalenso

Bug report

Bug description:

>>> def F(a,b):
...     x=a*b
...     frame = inspect.currentframe()
...     print(frame.__sizeof__())
...     return x
... 
>>> F(1,2)
184
>>> F.__code__ = F.__code__.replace(co_stacksize=1000)
>>> F(1,2)
8152
>>> F.__code__ = F.__code__.replace(co_stacksize=2147483646)
>>> F(1,2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: ../Modules/gcmodule.c:2313: bad argument to internal function

It happens due to overflow in frame_sizeof

CPython versions tested on:

3.11

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

Labels

3.12only security fixes3.13bugs and security fixes3.14new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dump

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions