Skip to content

TOS Caching does not handle Py_DECREF #142707

@Fidget-Spinner

Description

@Fidget-Spinner

Bug report

Bug description:

For example for the following code from #142703

def foo(l):
    for _ in range(4099):
        l[0] = 1
foo([0]

The following trace is generated:

   0 OPTIMIZED: _START_EXECUTOR_r00 (0, jump_target=21, operand0=0x61d7aa5bc790, operand1=0, error_target=0)
   1 OPTIMIZED: _MAKE_WARM_r00 (0, target=0, operand0=0, operand1=0)
   2 OPTIMIZED: _SET_IP_r00 (0, target=20, operand0=0x795204f5c498, operand1=0)
   3 OPTIMIZED: _CHECK_PERIODIC_r00 (0, jump_target=0, operand0=0, operand1=0)
   4 OPTIMIZED: _CHECK_VALIDITY_r00 (0, jump_target=23, operand0=0, operand1=0)
   5 OPTIMIZED: _ITER_CHECK_RANGE_r02 (8, jump_target=24, operand0=0, operand1=0, error_target=0)
   6 OPTIMIZED: _GUARD_NOT_EXHAUSTED_RANGE_r22 (8, jump_target=25, operand0=0, operand1=0, error_target=0)
   7 OPTIMIZED: _ITER_NEXT_RANGE_r23 (8, jump_target=0, operand0=0, operand1=0, error_target=26)
   8 OPTIMIZED: _SET_IP_r33 (0, target=14, operand0=0x795204f5c48c, operand1=0)
   9 OPTIMIZED: _SPILL_OR_RELOAD_r31 (0, target=0, operand0=0, operand1=0)
  10 OPTIMIZED: _STORE_FAST_1_r10 (1, target=14, operand0=0, operand1=0, error_target=0)
  11 OPTIMIZED: _CHECK_VALIDITY_r00 (0, jump_target=27, operand0=0, operand1=0)
  12 OPTIMIZED: _LOAD_CONST_INLINE_BORROW_r01 (0, target=15, operand0=0x61d7973c0508, operand1=0)
  13 OPTIMIZED: _LOAD_FAST_BORROW_0_r12 (0, target=16, operand0=0, operand1=0)
  14 OPTIMIZED: _LOAD_CONST_INLINE_BORROW_r23 (0, target=17, operand0=0x61d7973c04e8, operand1=0)
  15 OPTIMIZED: _SET_IP_r33 (0, target=18, operand0=0x795204f5c494, operand1=0)
  16 OPTIMIZED: _GUARD_NOS_LIST_r33 (0, jump_target=28, operand0=0, operand1=0)
  17 OPTIMIZED: _STORE_SUBSCR_LIST_INT_r32 (0, jump_target=29, operand0=0, operand1=0)
  18 OPTIMIZED: _POP_TOP_NOP_r21 (0, target=18, operand0=0, operand1=0)
  19 OPTIMIZED: _POP_TOP_NOP_r10 (0, target=18, operand0=0, operand1=0)
  20 OPTIMIZED: _JUMP_TO_TOP_r00 (0, jump_target=1, operand0=0, operand1=0)

_STORE_SUBSCR_LIST_INT has a Py_DECREF of the old value inside, but it doesn't seem to be spilling. The same thing is happening for POP_TOP.

@markshannon

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Metadata

Metadata

Assignees

Labels

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