Skip to content

BINARY_OP_SUBSCR_GETITEM constituent uops are invalid #140277

Description

@Fidget-Spinner

Bug report

Bug description:

The current JIT doesn't expose this bug as it doesn't project calls through BINARY_OP_SUBSCR_GETITEM. However, the problem is that the uop puts 3 things on the stack:

op(_BINARY_OP_SUBSCR_CHECK_FUNC, (container, unused -- container, unused, getitem)) {

However, BINARY_OP is only expected to have at most 2 items on the stack.

On my branch with recording the BINARY_OP_CHECK_FUNC, this causes a segfault due to stack overflow.

We should really re-add the code that calculates the maximum stack size from constituent uops. This is also blocking work on decref elimination in the JIT.

Example repro on my branch with trace recording:

class Get:
    def __getitem__(self, i):
        return i


g = Get()
def foo():
    for _ in range(4099):
        g[1]

foo()

@mpage (as author of the original PR to sum up uop stack effect) @markshannon

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)topic-JITtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions