FAILURE MAP
← Case archive

FA-90506 / Garbage collector invariants / Open access

Heap pacing: heap reset to zero after collection · case 01

Live data is forgotten, so the next trigger happens far too late.

Verified by executionVariant 1 · 7 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The collection resets the heap counter to zero instead of the surviving live bytes.

VERIFIED REPAIR

After a collection the heap holds exactly the live bytes.

Unsuccessful approach: Assigning the previous marked size uses the last cycle's survivors.

Case contract

GOGC-style pacing starting at 100 percent with goal = min_heap. alloc b adds b to the heap and to live bytes and triggers a collection when collection is enabled (percentage >= 0) and heap >= goal: the heap shrinks to the live bytes, which become the marked size, and goal = max(marked + marked * pct // 100, min_heap). drop b turns b live bytes into garbage. setgc p changes the percentage (-1 disables) and, unless disabled, recomputes the goal from the last marked size. Return the heap sizes at which collections triggered, the final goal and heap.

Why this case matters

Collector pacing decides when collections run; off-by-one or base errors change memory footprint.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events, min_heap):
    gogc = 100
    live = 0
    marked = 0
    heap = 0
    goal = min_heap
    gcs = []
    for ev in events:
        if ev[0] == 'alloc':
            heap += ev[1]
            live += ev[1]
            if gogc >= 0 and heap >= goal:
                gcs.append(heap)
                heap = 0
                marked = live
                goal = max(live + live * gogc // 100, min_heap)
        elif ev[0] == 'drop':
            live -= ev[1]
        else:
            gogc = ev[1]
            if gogc >= 0:
                goal = max(marked + marked * gogc // 100, min_heap)
    return {'gcs': gcs, 'goal': goal, 'heap': heap}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: heap reaching the goal exactly',
   ([['alloc', 55], ['alloc', 55], ['drop', 30], ['alloc', 25]], 110),
   {'gcs': [110], 'goal': 220, 'heap': 135}),
  ('goal grows with live heap',
   ([['alloc', 330], ['drop', 110], ['alloc', 220], ['alloc', 10]], 110),
   {'gcs': [330], 'goal': 660, 'heap': 560}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 220], ['alloc', 111]], 110),
   {'gcs': [220, 331], 'goal': 496, 'heap': 331}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 330], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 110),
   {'gcs': [331, 332], 'goal': 332, 'heap': 332}),
  ('goal recomputed from last marked heap',
   ([['alloc', 220], ['drop', 110], ['alloc', 10], ['setgc', 200], ['alloc', 330], ['alloc', 110]], 110),
   {'gcs': [220, 670], 'goal': 1680, 'heap': 560}),
  ('small live heap uses the minimum goal',
   ([['alloc', 110],
     ['drop', 110],
     ['alloc', 109],
     ['drop', 109],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 104]],
    110),
   {'gcs': [110, 220, 110], 'goal': 220, 'heap': 110}),
  ('control: no allocation', ([['setgc', 50]], 110), {'gcs': [], 'goal': 110, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 60], ['alloc', 60], ['drop', 30], ['alloc', 25]], 120),
   {'gcs': [120], 'goal': 240, 'heap': 145}),
  ('goal grows with live heap',
   ([['alloc', 360], ['drop', 120], ['alloc', 240], ['alloc', 10]], 120),
   {'gcs': [360], 'goal': 720, 'heap': 610}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 240], ['alloc', 121]], 120),
   {'gcs': [240, 361], 'goal': 541, 'heap': 361}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 360], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 120),
   {'gcs': [361, 362], 'goal': 362, 'heap': 362}),
  ('goal recomputed from last marked heap',
   ([['alloc', 240], ['drop', 120], ['alloc', 10], ['setgc', 200], ['alloc', 360], ['alloc', 120]], 120),
   {'gcs': [240, 730], 'goal': 1830, 'heap': 610}),
  ('small live heap uses the minimum goal',
   ([['alloc', 120],
     ['drop', 120],
     ['alloc', 119],
     ['drop', 119],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 114]],
    120),
   {'gcs': [120, 240, 120], 'goal': 240, 'heap': 120}),
  ('control: no allocation', ([['setgc', 50]], 120), {'gcs': [], 'goal': 120, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 65], ['alloc', 65], ['drop', 30], ['alloc', 25]], 130),
   {'gcs': [130], 'goal': 260, 'heap': 155}),
  ('goal grows with live heap',
   ([['alloc', 390], ['drop', 130], ['alloc', 260], ['alloc', 10]], 130),
   {'gcs': [390], 'goal': 780, 'heap': 660}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 260], ['alloc', 131]], 130),
   {'gcs': [260, 391], 'goal': 586, 'heap': 391}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 390], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 130),
   {'gcs': [391, 392], 'goal': 392, 'heap': 392}),
  ('goal recomputed from last marked heap',
   ([['alloc', 260], ['drop', 130], ['alloc', 10], ['setgc', 200], ['alloc', 390], ['alloc', 130]], 130),
   {'gcs': [260, 790], 'goal': 1980, 'heap': 660}),
  ('small live heap uses the minimum goal',
   ([['alloc', 130],
     ['drop', 130],
     ['alloc', 129],
     ['drop', 129],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 124]],
    130),
   {'gcs': [130, 260, 130], 'goal': 260, 'heap': 130}),
  ('control: no allocation', ([['setgc', 50]], 130), {'gcs': [], 'goal': 130, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 70], ['alloc', 70], ['drop', 30], ['alloc', 25]], 140),
   {'gcs': [140], 'goal': 280, 'heap': 165}),
  ('goal grows with live heap',
   ([['alloc', 420], ['drop', 140], ['alloc', 280], ['alloc', 10]], 140),
   {'gcs': [420], 'goal': 840, 'heap': 710}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 280], ['alloc', 141]], 140),
   {'gcs': [280, 421], 'goal': 631, 'heap': 421}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 420], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 140),
   {'gcs': [421, 422], 'goal': 422, 'heap': 422}),
  ('goal recomputed from last marked heap',
   ([['alloc', 280], ['drop', 140], ['alloc', 10], ['setgc', 200], ['alloc', 420], ['alloc', 140]], 140),
   {'gcs': [280, 850], 'goal': 2130, 'heap': 710}),
  ('small live heap uses the minimum goal',
   ([['alloc', 140],
     ['drop', 140],
     ['alloc', 139],
     ['drop', 139],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 134]],
    140),
   {'gcs': [140, 280, 140], 'goal': 280, 'heap': 140}),
  ('control: no allocation', ([['setgc', 50]], 140), {'gcs': [], 'goal': 140, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 75], ['alloc', 75], ['drop', 30], ['alloc', 25]], 150),
   {'gcs': [150], 'goal': 300, 'heap': 175}),
  ('goal grows with live heap',
   ([['alloc', 450], ['drop', 150], ['alloc', 300], ['alloc', 10]], 150),
   {'gcs': [450], 'goal': 900, 'heap': 760}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 300], ['alloc', 151]], 150),
   {'gcs': [300, 451], 'goal': 676, 'heap': 451}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 450], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 150),
   {'gcs': [451, 452], 'goal': 452, 'heap': 452}),
  ('goal recomputed from last marked heap',
   ([['alloc', 300], ['drop', 150], ['alloc', 10], ['setgc', 200], ['alloc', 450], ['alloc', 150]], 150),
   {'gcs': [300, 910], 'goal': 2280, 'heap': 760}),
  ('small live heap uses the minimum goal',
   ([['alloc', 150],
     ['drop', 150],
     ['alloc', 149],
     ['drop', 149],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 144]],
    150),
   {'gcs': [150, 300, 150], 'goal': 300, 'heap': 150}),
  ('control: no allocation', ([['setgc', 50]], 150), {'gcs': [], 'goal': 150, 'heap': 0})]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: heap reaching the goal exactly{'gcs': [110], 'goal': 220, 'heap': 25}{'gcs': [110], 'goal': 220, 'heap': 135}Failed
goal grows with live heap{'gcs': [330], 'goal': 660, 'heap': 230}{'gcs': [330], 'goal': 660, 'heap': 560}Failed
fractional growth percentage{'gcs': [220], 'goal': 330, 'heap': 111}{'gcs': [220, 331], 'goal': 496, 'heap': 331}Failed
collector disabled then zero percent{'gcs': [331], 'goal': 331, 'heap': 1}{'gcs': [331, 332], 'goal': 332, 'heap': 332}Failed
goal recomputed from last marked heap{'gcs': [220], 'goal': 660, 'heap': 450}{'gcs': [220, 670], 'goal': 1680, 'heap': 560}Failed
small live heap uses the minimum goal{'gcs': [110], 'goal': 220, 'heap': 219}{'gcs': [110, 220, 110], 'goal': 220, 'heap': 110}Failed
control: no allocation{'gcs': [], 'goal': 110, 'heap': 0}{'gcs': [], 'goal': 110, 'heap': 0}Passed

SHA-256 / a43eb875f38a3298108f5d7692f16e3bd9d91b9e492b200fd0ed067223e9648d

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events, min_heap):
    gogc = 100
    live = 0
    marked = 0
    heap = 0
    goal = min_heap
    gcs = []
    for ev in events:
        if ev[0] == 'alloc':
            heap += ev[1]
            live += ev[1]
            if gogc >= 0 and heap >= goal:
                gcs.append(heap)
                heap = marked
                marked = live
                goal = max(live + live * gogc // 100, min_heap)
        elif ev[0] == 'drop':
            live -= ev[1]
        else:
            gogc = ev[1]
            if gogc >= 0:
                goal = max(marked + marked * gogc // 100, min_heap)
    return {'gcs': gcs, 'goal': goal, 'heap': heap}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: heap reaching the goal exactly',
   ([['alloc', 55], ['alloc', 55], ['drop', 30], ['alloc', 25]], 110),
   {'gcs': [110], 'goal': 220, 'heap': 135}),
  ('goal grows with live heap',
   ([['alloc', 330], ['drop', 110], ['alloc', 220], ['alloc', 10]], 110),
   {'gcs': [330], 'goal': 660, 'heap': 560}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 220], ['alloc', 111]], 110),
   {'gcs': [220, 331], 'goal': 496, 'heap': 331}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 330], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 110),
   {'gcs': [331, 332], 'goal': 332, 'heap': 332}),
  ('goal recomputed from last marked heap',
   ([['alloc', 220], ['drop', 110], ['alloc', 10], ['setgc', 200], ['alloc', 330], ['alloc', 110]], 110),
   {'gcs': [220, 670], 'goal': 1680, 'heap': 560}),
  ('small live heap uses the minimum goal',
   ([['alloc', 110],
     ['drop', 110],
     ['alloc', 109],
     ['drop', 109],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 104]],
    110),
   {'gcs': [110, 220, 110], 'goal': 220, 'heap': 110}),
  ('control: no allocation', ([['setgc', 50]], 110), {'gcs': [], 'goal': 110, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 60], ['alloc', 60], ['drop', 30], ['alloc', 25]], 120),
   {'gcs': [120], 'goal': 240, 'heap': 145}),
  ('goal grows with live heap',
   ([['alloc', 360], ['drop', 120], ['alloc', 240], ['alloc', 10]], 120),
   {'gcs': [360], 'goal': 720, 'heap': 610}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 240], ['alloc', 121]], 120),
   {'gcs': [240, 361], 'goal': 541, 'heap': 361}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 360], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 120),
   {'gcs': [361, 362], 'goal': 362, 'heap': 362}),
  ('goal recomputed from last marked heap',
   ([['alloc', 240], ['drop', 120], ['alloc', 10], ['setgc', 200], ['alloc', 360], ['alloc', 120]], 120),
   {'gcs': [240, 730], 'goal': 1830, 'heap': 610}),
  ('small live heap uses the minimum goal',
   ([['alloc', 120],
     ['drop', 120],
     ['alloc', 119],
     ['drop', 119],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 114]],
    120),
   {'gcs': [120, 240, 120], 'goal': 240, 'heap': 120}),
  ('control: no allocation', ([['setgc', 50]], 120), {'gcs': [], 'goal': 120, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 65], ['alloc', 65], ['drop', 30], ['alloc', 25]], 130),
   {'gcs': [130], 'goal': 260, 'heap': 155}),
  ('goal grows with live heap',
   ([['alloc', 390], ['drop', 130], ['alloc', 260], ['alloc', 10]], 130),
   {'gcs': [390], 'goal': 780, 'heap': 660}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 260], ['alloc', 131]], 130),
   {'gcs': [260, 391], 'goal': 586, 'heap': 391}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 390], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 130),
   {'gcs': [391, 392], 'goal': 392, 'heap': 392}),
  ('goal recomputed from last marked heap',
   ([['alloc', 260], ['drop', 130], ['alloc', 10], ['setgc', 200], ['alloc', 390], ['alloc', 130]], 130),
   {'gcs': [260, 790], 'goal': 1980, 'heap': 660}),
  ('small live heap uses the minimum goal',
   ([['alloc', 130],
     ['drop', 130],
     ['alloc', 129],
     ['drop', 129],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 124]],
    130),
   {'gcs': [130, 260, 130], 'goal': 260, 'heap': 130}),
  ('control: no allocation', ([['setgc', 50]], 130), {'gcs': [], 'goal': 130, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 70], ['alloc', 70], ['drop', 30], ['alloc', 25]], 140),
   {'gcs': [140], 'goal': 280, 'heap': 165}),
  ('goal grows with live heap',
   ([['alloc', 420], ['drop', 140], ['alloc', 280], ['alloc', 10]], 140),
   {'gcs': [420], 'goal': 840, 'heap': 710}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 280], ['alloc', 141]], 140),
   {'gcs': [280, 421], 'goal': 631, 'heap': 421}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 420], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 140),
   {'gcs': [421, 422], 'goal': 422, 'heap': 422}),
  ('goal recomputed from last marked heap',
   ([['alloc', 280], ['drop', 140], ['alloc', 10], ['setgc', 200], ['alloc', 420], ['alloc', 140]], 140),
   {'gcs': [280, 850], 'goal': 2130, 'heap': 710}),
  ('small live heap uses the minimum goal',
   ([['alloc', 140],
     ['drop', 140],
     ['alloc', 139],
     ['drop', 139],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 134]],
    140),
   {'gcs': [140, 280, 140], 'goal': 280, 'heap': 140}),
  ('control: no allocation', ([['setgc', 50]], 140), {'gcs': [], 'goal': 140, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 75], ['alloc', 75], ['drop', 30], ['alloc', 25]], 150),
   {'gcs': [150], 'goal': 300, 'heap': 175}),
  ('goal grows with live heap',
   ([['alloc', 450], ['drop', 150], ['alloc', 300], ['alloc', 10]], 150),
   {'gcs': [450], 'goal': 900, 'heap': 760}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 300], ['alloc', 151]], 150),
   {'gcs': [300, 451], 'goal': 676, 'heap': 451}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 450], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 150),
   {'gcs': [451, 452], 'goal': 452, 'heap': 452}),
  ('goal recomputed from last marked heap',
   ([['alloc', 300], ['drop', 150], ['alloc', 10], ['setgc', 200], ['alloc', 450], ['alloc', 150]], 150),
   {'gcs': [300, 910], 'goal': 2280, 'heap': 760}),
  ('small live heap uses the minimum goal',
   ([['alloc', 150],
     ['drop', 150],
     ['alloc', 149],
     ['drop', 149],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 144]],
    150),
   {'gcs': [150, 300, 150], 'goal': 300, 'heap': 150}),
  ('control: no allocation', ([['setgc', 50]], 150), {'gcs': [], 'goal': 150, 'heap': 0})]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: heap reaching the goal exactly{'gcs': [110], 'goal': 220, 'heap': 25}{'gcs': [110], 'goal': 220, 'heap': 135}Failed
goal grows with live heap{'gcs': [330], 'goal': 660, 'heap': 230}{'gcs': [330], 'goal': 660, 'heap': 560}Failed
fractional growth percentage{'gcs': [220], 'goal': 330, 'heap': 111}{'gcs': [220, 331], 'goal': 496, 'heap': 331}Failed
collector disabled then zero percent{'gcs': [331], 'goal': 331, 'heap': 1}{'gcs': [331, 332], 'goal': 332, 'heap': 332}Failed
goal recomputed from last marked heap{'gcs': [220], 'goal': 660, 'heap': 450}{'gcs': [220, 670], 'goal': 1680, 'heap': 560}Failed
small live heap uses the minimum goal{'gcs': [110], 'goal': 220, 'heap': 219}{'gcs': [110, 220, 110], 'goal': 220, 'heap': 110}Failed
control: no allocation{'gcs': [], 'goal': 110, 'heap': 0}{'gcs': [], 'goal': 110, 'heap': 0}Passed

SHA-256 / 33a10838cfe89c5043b61f500f817269241e0690defa4e0dcb849996f8606f6b

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(events, min_heap):
    gogc = 100
    live = 0
    marked = 0
    heap = 0
    goal = min_heap
    gcs = []
    for ev in events:
        if ev[0] == 'alloc':
            heap += ev[1]
            live += ev[1]
            if gogc >= 0 and heap >= goal:
                gcs.append(heap)
                heap = live
                marked = live
                goal = max(live + live * gogc // 100, min_heap)
        elif ev[0] == 'drop':
            live -= ev[1]
        else:
            gogc = ev[1]
            if gogc >= 0:
                goal = max(marked + marked * gogc // 100, min_heap)
    return {'gcs': gcs, 'goal': goal, 'heap': heap}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: heap reaching the goal exactly',
   ([['alloc', 55], ['alloc', 55], ['drop', 30], ['alloc', 25]], 110),
   {'gcs': [110], 'goal': 220, 'heap': 135}),
  ('goal grows with live heap',
   ([['alloc', 330], ['drop', 110], ['alloc', 220], ['alloc', 10]], 110),
   {'gcs': [330], 'goal': 660, 'heap': 560}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 220], ['alloc', 111]], 110),
   {'gcs': [220, 331], 'goal': 496, 'heap': 331}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 330], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 110),
   {'gcs': [331, 332], 'goal': 332, 'heap': 332}),
  ('goal recomputed from last marked heap',
   ([['alloc', 220], ['drop', 110], ['alloc', 10], ['setgc', 200], ['alloc', 330], ['alloc', 110]], 110),
   {'gcs': [220, 670], 'goal': 1680, 'heap': 560}),
  ('small live heap uses the minimum goal',
   ([['alloc', 110],
     ['drop', 110],
     ['alloc', 109],
     ['drop', 109],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 104]],
    110),
   {'gcs': [110, 220, 110], 'goal': 220, 'heap': 110}),
  ('control: no allocation', ([['setgc', 50]], 110), {'gcs': [], 'goal': 110, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 60], ['alloc', 60], ['drop', 30], ['alloc', 25]], 120),
   {'gcs': [120], 'goal': 240, 'heap': 145}),
  ('goal grows with live heap',
   ([['alloc', 360], ['drop', 120], ['alloc', 240], ['alloc', 10]], 120),
   {'gcs': [360], 'goal': 720, 'heap': 610}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 240], ['alloc', 121]], 120),
   {'gcs': [240, 361], 'goal': 541, 'heap': 361}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 360], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 120),
   {'gcs': [361, 362], 'goal': 362, 'heap': 362}),
  ('goal recomputed from last marked heap',
   ([['alloc', 240], ['drop', 120], ['alloc', 10], ['setgc', 200], ['alloc', 360], ['alloc', 120]], 120),
   {'gcs': [240, 730], 'goal': 1830, 'heap': 610}),
  ('small live heap uses the minimum goal',
   ([['alloc', 120],
     ['drop', 120],
     ['alloc', 119],
     ['drop', 119],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 114]],
    120),
   {'gcs': [120, 240, 120], 'goal': 240, 'heap': 120}),
  ('control: no allocation', ([['setgc', 50]], 120), {'gcs': [], 'goal': 120, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 65], ['alloc', 65], ['drop', 30], ['alloc', 25]], 130),
   {'gcs': [130], 'goal': 260, 'heap': 155}),
  ('goal grows with live heap',
   ([['alloc', 390], ['drop', 130], ['alloc', 260], ['alloc', 10]], 130),
   {'gcs': [390], 'goal': 780, 'heap': 660}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 260], ['alloc', 131]], 130),
   {'gcs': [260, 391], 'goal': 586, 'heap': 391}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 390], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 130),
   {'gcs': [391, 392], 'goal': 392, 'heap': 392}),
  ('goal recomputed from last marked heap',
   ([['alloc', 260], ['drop', 130], ['alloc', 10], ['setgc', 200], ['alloc', 390], ['alloc', 130]], 130),
   {'gcs': [260, 790], 'goal': 1980, 'heap': 660}),
  ('small live heap uses the minimum goal',
   ([['alloc', 130],
     ['drop', 130],
     ['alloc', 129],
     ['drop', 129],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 124]],
    130),
   {'gcs': [130, 260, 130], 'goal': 260, 'heap': 130}),
  ('control: no allocation', ([['setgc', 50]], 130), {'gcs': [], 'goal': 130, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 70], ['alloc', 70], ['drop', 30], ['alloc', 25]], 140),
   {'gcs': [140], 'goal': 280, 'heap': 165}),
  ('goal grows with live heap',
   ([['alloc', 420], ['drop', 140], ['alloc', 280], ['alloc', 10]], 140),
   {'gcs': [420], 'goal': 840, 'heap': 710}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 280], ['alloc', 141]], 140),
   {'gcs': [280, 421], 'goal': 631, 'heap': 421}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 420], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 140),
   {'gcs': [421, 422], 'goal': 422, 'heap': 422}),
  ('goal recomputed from last marked heap',
   ([['alloc', 280], ['drop', 140], ['alloc', 10], ['setgc', 200], ['alloc', 420], ['alloc', 140]], 140),
   {'gcs': [280, 850], 'goal': 2130, 'heap': 710}),
  ('small live heap uses the minimum goal',
   ([['alloc', 140],
     ['drop', 140],
     ['alloc', 139],
     ['drop', 139],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 134]],
    140),
   {'gcs': [140, 280, 140], 'goal': 280, 'heap': 140}),
  ('control: no allocation', ([['setgc', 50]], 140), {'gcs': [], 'goal': 140, 'heap': 0})],
 [('regression: heap reaching the goal exactly',
   ([['alloc', 75], ['alloc', 75], ['drop', 30], ['alloc', 25]], 150),
   {'gcs': [150], 'goal': 300, 'heap': 175}),
  ('goal grows with live heap',
   ([['alloc', 450], ['drop', 150], ['alloc', 300], ['alloc', 10]], 150),
   {'gcs': [450], 'goal': 900, 'heap': 760}),
  ('fractional growth percentage',
   ([['setgc', 50], ['alloc', 300], ['alloc', 151]], 150),
   {'gcs': [300, 451], 'goal': 676, 'heap': 451}),
  ('collector disabled then zero percent',
   ([['setgc', -1], ['alloc', 450], ['setgc', 0], ['alloc', 1], ['alloc', 1]], 150),
   {'gcs': [451, 452], 'goal': 452, 'heap': 452}),
  ('goal recomputed from last marked heap',
   ([['alloc', 300], ['drop', 150], ['alloc', 10], ['setgc', 200], ['alloc', 450], ['alloc', 150]], 150),
   {'gcs': [300, 910], 'goal': 2280, 'heap': 760}),
  ('small live heap uses the minimum goal',
   ([['alloc', 150],
     ['drop', 150],
     ['alloc', 149],
     ['drop', 149],
     ['alloc', 1],
     ['alloc', 5],
     ['alloc', 144]],
    150),
   {'gcs': [150, 300, 150], 'goal': 300, 'heap': 150}),
  ('control: no allocation', ([['setgc', 50]], 150), {'gcs': [], 'goal': 150, 'heap': 0})]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: heap reaching the goal exactly{'gcs': [110], 'goal': 220, 'heap': 135}{'gcs': [110], 'goal': 220, 'heap': 135}Passed
goal grows with live heap{'gcs': [330], 'goal': 660, 'heap': 560}{'gcs': [330], 'goal': 660, 'heap': 560}Passed
fractional growth percentage{'gcs': [220, 331], 'goal': 496, 'heap': 331}{'gcs': [220, 331], 'goal': 496, 'heap': 331}Passed
collector disabled then zero percent{'gcs': [331, 332], 'goal': 332, 'heap': 332}{'gcs': [331, 332], 'goal': 332, 'heap': 332}Passed
goal recomputed from last marked heap{'gcs': [220, 670], 'goal': 1680, 'heap': 560}{'gcs': [220, 670], 'goal': 1680, 'heap': 560}Passed
small live heap uses the minimum goal{'gcs': [110, 220, 110], 'goal': 220, 'heap': 110}{'gcs': [110, 220, 110], 'goal': 220, 'heap': 110}Passed
control: no allocation{'gcs': [], 'goal': 110, 'heap': 0}{'gcs': [], 'goal': 110, 'heap': 0}Passed

SHA-256 / 5395f4c4d9801b7ec7294bd530511772d826ee600e9d6016b2993249d762f12d

Verification & scope

A deterministic, bounded teaching model of one garbage-collector mechanism with stipulated rules; it is not a production collector and claims no conformance to any particular runtime. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:51:27.263506+00:00.

Case digest / 47ec74cabccd943673187b713ccdde39bbe74053b9c6bdb81b3c60d252263927