Skip to content

infer: an infinite loop over a spy grows the trace until the memory is gone #873

Open

Description

@jorenham

Split off from #774, which covers the sys.settrace mechanism. This one is an infinite loop over a spy:

import multiprocessing.heap
infer(multiprocessing.heap.Heap._free_pending_blocks)
while True:
    try:
        block = self._pending_free_blocks.pop()
    except IndexError:
        break
    ...

self._pending_free_blocks.pop() on a spy never raises IndexError, so the loop runs until the 60 s isolate timeout. Every iteration appends to the trace, so memory grows at roughly 4 GB per 12 s: under a 4 GB RLIMIT_AS it ends in InferError: the function never ran to completion (MemoryError), without a cap it exhausts the machine first.

Nothing bounds the number of operations a single run records; the run, fork, and yield budgets do not apply to a loop that never forks or yields. A per-run operation cap (raised as a BaseException so the target cannot swallow it, and reported as an exploration gap) would end this class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions