FA-90311 / Bytecode virtual machines / Open access
Stack map frames: first frame offset shifted by one · case 01
Every frame is attached to the instruction after the one it describes.
ROOT CAUSE
The +1 separator is applied to the first frame as well.
VERIFIED REPAIR
Use delta for the first frame and previous + delta + 1 afterwards.
Unsuccessful approach: Dropping the +1 for later frames collapses consecutive frames onto the wrong offsets.
Case contract
Expand compressed stack map frames. Types: 0-63 same (delta = type), 64-127 same_locals_1_stack_item (delta = type - 64, one stack item), 128-246 reserved (["ClassFormatError", index]), 247 extended one item [247, delta, item], 248-250 chop 251-type locals [t, delta], 251 same extended [251, delta], 252-254 append type-251 locals [t, delta, items...], 255 full [255, delta, locals, stack]. The first frame's offset is its delta; each later offset is previous + delta + 1. Chopping more locals than exist is an error. Return [offset, locals, stack] for every frame; each frame's locals are an independent snapshot.
Why this case matters
Verifiers reconstruct per-offset types from this compressed encoding; any slip mistypes locals.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(initial, frames):
locals_ = list(initial)
out = []
offset = 0
for idx, fr in enumerate(frames):
t = fr[0]
stack = []
if t <= 63:
delta = t
elif t <= 127:
delta = t - 64
stack = [fr[1]]
elif t < 247:
return ['ClassFormatError', idx]
elif t == 247:
delta = fr[1]
stack = [fr[2]]
elif t <= 250:
delta = fr[1]
k = 251 - t
if k > len(locals_):
return ['ClassFormatError', idx]
locals_ = locals_[:len(locals_) - k]
elif t == 251:
delta = fr[1]
elif t <= 254:
delta = fr[1]
locals_ = locals_ + list(fr[2:2 + t - 251])
else:
delta = fr[1]
locals_ = list(fr[2])
stack = list(fr[3])
offset = offset + delta + 1
out.append([offset, locals_, stack])
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: every compressed frame kind',
(['I', 'Object'], [[5], [71, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
[[5, ['I', 'Object'], []],
[13, ['I', 'Object'], ['I']],
[17, ['I', 'Object', 'F'], []],
[20, ['I'], []],
[321, ['I'], []],
[323, ['I'], ['Object', 'J']]]),
('first frame offset is its delta',
(['I', 'Object'], [[11], [3]]),
[[11, ['I', 'Object'], []], [15, ['I', 'Object'], []]]),
('same_locals_1_stack_item delta',
(['I', 'Object'], [[65, 'Object'], [64, 'I']]),
[[1, ['I', 'Object'], ['Object']], [2, ['I', 'Object'], ['I']]]),
('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
('extended one-item frame type',
(['I', 'Object'], [[247, 5, 'Object']]),
[[5, ['I', 'Object'], ['Object']]]),
('chop three locals', (['I', 'J', 'F'], [[248, 1], [251, 0]]), [[1, [], []], [2, [], []]]),
('chop more locals than exist', ([], [[250, 1]]), ['ClassFormatError', 0]),
('append three locals then snapshot',
(['I', 'Object'], [[0], [254, 1, 'I', 'I', 'F'], [0]]),
[[0, ['I', 'Object'], []],
[2, ['I', 'Object', 'I', 'I', 'F'], []],
[3, ['I', 'Object', 'I', 'I', 'F'], []]]),
('control: full frame replaces locals',
(['I', 'Object'], [[255, 1, ['Object'], []], [2]]),
[[1, ['Object'], []], [4, ['Object'], []]])],
[('regression: every compressed frame kind',
(['I', 'Object'], [[5], [72, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
[[5, ['I', 'Object'], []],
[14, ['I', 'Object'], ['I']],
[18, ['I', 'Object', 'F'], []],
[21, ['I'], []],
[322, ['I'], []],
[324, ['I'], ['Object', 'J']]]),
('first frame offset is its delta',
(['I', 'Object'], [[12], [3]]),
[[12, ['I', 'Object'], []], [16, ['I', 'Object'], []]]),
('same_locals_1_stack_item delta',
(['I', 'Object'], [[66, 'Object'], [64, 'I']]),
[[2, ['I', 'Object'], ['Object']], [3, ['I', 'Object'], ['I']]]),
('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
('extended one-item frame type',
(['I', 'Object'], [[247, 6, 'Object']]),
[[6, ['I', 'Object'], ['Object']]]),
('chop three locals', (['I', 'J', 'F'], [[248, 2], [251, 0]]), [[2, [], []], [3, [], []]]),
('chop more locals than exist', ([], [[250, 2]]), ['ClassFormatError', 0]),
('append three locals then snapshot',
(['I', 'Object'], [[0], [254, 2, 'I', 'I', 'F'], [0]]),
[[0, ['I', 'Object'], []],
[3, ['I', 'Object', 'I', 'I', 'F'], []],
[4, ['I', 'Object', 'I', 'I', 'F'], []]]),
('control: full frame replaces locals',
(['I', 'Object'], [[255, 2, ['Object'], []], [2]]),
[[2, ['Object'], []], [5, ['Object'], []]])],
[('regression: every compressed frame kind',
(['I', 'Object'], [[5], [73, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
[[5, ['I', 'Object'], []],
[15, ['I', 'Object'], ['I']],
[19, ['I', 'Object', 'F'], []],
[22, ['I'], []],
[323, ['I'], []],
[325, ['I'], ['Object', 'J']]]),
('first frame offset is its delta',
(['I', 'Object'], [[13], [3]]),
[[13, ['I', 'Object'], []], [17, ['I', 'Object'], []]]),
('same_locals_1_stack_item delta',
(['I', 'Object'], [[67, 'Object'], [64, 'I']]),
[[3, ['I', 'Object'], ['Object']], [4, ['I', 'Object'], ['I']]]),
('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
('extended one-item frame type',
(['I', 'Object'], [[247, 7, 'Object']]),
[[7, ['I', 'Object'], ['Object']]]),
('chop three locals', (['I', 'J', 'F'], [[248, 3], [251, 0]]), [[3, [], []], [4, [], []]]),
('chop more locals than exist', ([], [[250, 3]]), ['ClassFormatError', 0]),
('append three locals then snapshot',
(['I', 'Object'], [[0], [254, 3, 'I', 'I', 'F'], [0]]),
[[0, ['I', 'Object'], []],
[4, ['I', 'Object', 'I', 'I', 'F'], []],
[5, ['I', 'Object', 'I', 'I', 'F'], []]]),
('control: full frame replaces locals',
(['I', 'Object'], [[255, 3, ['Object'], []], [2]]),
[[3, ['Object'], []], [6, ['Object'], []]])],
[('regression: every compressed frame kind',
(['I', 'Object'], [[5], [74, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
[[5, ['I', 'Object'], []],
[16, ['I', 'Object'], ['I']],
[20, ['I', 'Object', 'F'], []],
[23, ['I'], []],
[324, ['I'], []],
[326, ['I'], ['Object', 'J']]]),
('first frame offset is its delta',
(['I', 'Object'], [[14], [3]]),
[[14, ['I', 'Object'], []], [18, ['I', 'Object'], []]]),
('same_locals_1_stack_item delta',
(['I', 'Object'], [[68, 'Object'], [64, 'I']]),
[[4, ['I', 'Object'], ['Object']], [5, ['I', 'Object'], ['I']]]),
('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
('extended one-item frame type',
(['I', 'Object'], [[247, 8, 'Object']]),
[[8, ['I', 'Object'], ['Object']]]),
('chop three locals', (['I', 'J', 'F'], [[248, 4], [251, 0]]), [[4, [], []], [5, [], []]]),
('chop more locals than exist', ([], [[250, 4]]), ['ClassFormatError', 0]),
('append three locals then snapshot',
(['I', 'Object'], [[0], [254, 4, 'I', 'I', 'F'], [0]]),
[[0, ['I', 'Object'], []],
[5, ['I', 'Object', 'I', 'I', 'F'], []],
[6, ['I', 'Object', 'I', 'I', 'F'], []]]),
('control: full frame replaces locals',
(['I', 'Object'], [[255, 4, ['Object'], []], [2]]),
[[4, ['Object'], []], [7, ['Object'], []]])],
[('regression: every compressed frame kind',
(['I', 'Object'], [[5], [75, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
[[5, ['I', 'Object'], []],
[17, ['I', 'Object'], ['I']],
[21, ['I', 'Object', 'F'], []],
[24, ['I'], []],
[325, ['I'], []],
[327, ['I'], ['Object', 'J']]]),
('first frame offset is its delta',
(['I', 'Object'], [[15], [3]]),
[[15, ['I', 'Object'], []], [19, ['I', 'Object'], []]]),
('same_locals_1_stack_item delta',
(['I', 'Object'], [[69, 'Object'], [64, 'I']]),
[[5, ['I', 'Object'], ['Object']], [6, ['I', 'Object'], ['I']]]),
('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
('extended one-item frame type',
(['I', 'Object'], [[247, 9, 'Object']]),
[[9, ['I', 'Object'], ['Object']]]),
('chop three locals', (['I', 'J', 'F'], [[248, 5], [251, 0]]), [[5, [], []], [6, [], []]]),
('chop more locals than exist', ([], [[250, 5]]), ['ClassFormatError', 0]),
('append three locals then snapshot',
(['I', 'Object'], [[0], [254, 5, 'I', 'I', 'F'], [0]]),
[[0, ['I', 'Object'], []],
[6, ['I', 'Object', 'I', 'I', 'F'], []],
[7, ['I', 'Object', 'I', 'I', 'F'], []]]),
('control: full frame replaces locals',
(['I', 'Object'], [[255, 5, ['Object'], []], [2]]),
[[5, ['Object'], []], [8, ['Object'], []]])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: every compressed frame kind | [[6, ['I', 'Object'], []], [14, ['I', 'Object'], ['I']], [18, ['I', 'Object', 'F'], []], [21, ['I'], []], [322, ['I'], []], [324, ['I'], ['Object', 'J']]] | [[5, ['I', 'Object'], []], [13, ['I', 'Object'], ['I']], [17, ['I', 'Object', 'F'], []], [20, ['I'], []], [321, ['I'], []], [323, ['I'], ['Object', 'J']]] | Failed |
| first frame offset is its delta | [[12, ['I', 'Object'], []], [16, ['I', 'Object'], []]] | [[11, ['I', 'Object'], []], [15, ['I', 'Object'], []]] | Failed |
| same_locals_1_stack_item delta | [[2, ['I', 'Object'], ['Object']], [3, ['I', 'Object'], ['I']]] | [[1, ['I', 'Object'], ['Object']], [2, ['I', 'Object'], ['I']]] | Failed |
| reserved frame type | ['ClassFormatError', 1] | ['ClassFormatError', 1] | Passed |
| extended one-item frame type | [[6, ['I', 'Object'], ['Object']]] | [[5, ['I', 'Object'], ['Object']]] | Failed |
| chop three locals | [[2, [], []], [3, [], []]] | [[1, [], []], [2, [], []]] | Failed |
| chop more locals than exist | ['ClassFormatError', 0] | ['ClassFormatError', 0] | Passed |
| append three locals then snapshot | [[1, ['I', 'Object'], []], [3, ['I', 'Object', 'I', 'I', 'F'], []], [4, ['I', 'Object', 'I', 'I', 'F'], []]] | [[0, ['I', 'Object'], []], [2, ['I', 'Object', 'I', 'I', 'F'], []], [3, ['I', 'Object', 'I', 'I', 'F'], []]] | Failed |
| control: full frame replaces locals | [[2, ['Object'], []], [5, ['Object'], []]] | [[1, ['Object'], []], [4, ['Object'], []]] | Failed |
SHA-256 / b490c5e6f14b1e85d751f19c43fdac15bd243fd4738c9e1ed7f0d82233a51ace
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(initial, frames):
locals_ = list(initial)
out = []
offset = 0
for idx, fr in enumerate(frames):
t = fr[0]
stack = []
if t <= 63:
delta = t
elif t <= 127:
delta = t - 64
stack = [fr[1]]
elif t < 247:
return ['ClassFormatError', idx]
elif t == 247:
delta = fr[1]
stack = [fr[2]]
elif t <= 250:
delta = fr[1]
k = 251 - t
if k > len(locals_):
return ['ClassFormatError', idx]
locals_ = locals_[:len(locals_) - k]
elif t == 251:
delta = fr[1]
elif t <= 254:
delta = fr[1]
locals_ = locals_ + list(fr[2:2 + t - 251])
else:
delta = fr[1]
locals_ = list(fr[2])
stack = list(fr[3])
offset = delta if idx == 0 else offset + delta
out.append([offset, locals_, stack])
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: every compressed frame kind',
(['I', 'Object'], [[5], [71, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
[[5, ['I', 'Object'], []],
[13, ['I', 'Object'], ['I']],
[17, ['I', 'Object', 'F'], []],
[20, ['I'], []],
[321, ['I'], []],
[323, ['I'], ['Object', 'J']]]),
('first frame offset is its delta',
(['I', 'Object'], [[11], [3]]),
[[11, ['I', 'Object'], []], [15, ['I', 'Object'], []]]),
('same_locals_1_stack_item delta',
(['I', 'Object'], [[65, 'Object'], [64, 'I']]),
[[1, ['I', 'Object'], ['Object']], [2, ['I', 'Object'], ['I']]]),
('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
('extended one-item frame type',
(['I', 'Object'], [[247, 5, 'Object']]),
[[5, ['I', 'Object'], ['Object']]]),
('chop three locals', (['I', 'J', 'F'], [[248, 1], [251, 0]]), [[1, [], []], [2, [], []]]),
('chop more locals than exist', ([], [[250, 1]]), ['ClassFormatError', 0]),
('append three locals then snapshot',
(['I', 'Object'], [[0], [254, 1, 'I', 'I', 'F'], [0]]),
[[0, ['I', 'Object'], []],
[2, ['I', 'Object', 'I', 'I', 'F'], []],
[3, ['I', 'Object', 'I', 'I', 'F'], []]]),
('control: full frame replaces locals',
(['I', 'Object'], [[255, 1, ['Object'], []], [2]]),
[[1, ['Object'], []], [4, ['Object'], []]])],
[('regression: every compressed frame kind',
(['I', 'Object'], [[5], [72, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
[[5, ['I', 'Object'], []],
[14, ['I', 'Object'], ['I']],
[18, ['I', 'Object', 'F'], []],
[21, ['I'], []],
[322, ['I'], []],
[324, ['I'], ['Object', 'J']]]),
('first frame offset is its delta',
(['I', 'Object'], [[12], [3]]),
[[12, ['I', 'Object'], []], [16, ['I', 'Object'], []]]),
('same_locals_1_stack_item delta',
(['I', 'Object'], [[66, 'Object'], [64, 'I']]),
[[2, ['I', 'Object'], ['Object']], [3, ['I', 'Object'], ['I']]]),
('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
('extended one-item frame type',
(['I', 'Object'], [[247, 6, 'Object']]),
[[6, ['I', 'Object'], ['Object']]]),
('chop three locals', (['I', 'J', 'F'], [[248, 2], [251, 0]]), [[2, [], []], [3, [], []]]),
('chop more locals than exist', ([], [[250, 2]]), ['ClassFormatError', 0]),
('append three locals then snapshot',
(['I', 'Object'], [[0], [254, 2, 'I', 'I', 'F'], [0]]),
[[0, ['I', 'Object'], []],
[3, ['I', 'Object', 'I', 'I', 'F'], []],
[4, ['I', 'Object', 'I', 'I', 'F'], []]]),
('control: full frame replaces locals',
(['I', 'Object'], [[255, 2, ['Object'], []], [2]]),
[[2, ['Object'], []], [5, ['Object'], []]])],
[('regression: every compressed frame kind',
(['I', 'Object'], [[5], [73, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
[[5, ['I', 'Object'], []],
[15, ['I', 'Object'], ['I']],
[19, ['I', 'Object', 'F'], []],
[22, ['I'], []],
[323, ['I'], []],
[325, ['I'], ['Object', 'J']]]),
('first frame offset is its delta',
(['I', 'Object'], [[13], [3]]),
[[13, ['I', 'Object'], []], [17, ['I', 'Object'], []]]),
('same_locals_1_stack_item delta',
(['I', 'Object'], [[67, 'Object'], [64, 'I']]),
[[3, ['I', 'Object'], ['Object']], [4, ['I', 'Object'], ['I']]]),
('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
('extended one-item frame type',
(['I', 'Object'], [[247, 7, 'Object']]),
[[7, ['I', 'Object'], ['Object']]]),
('chop three locals', (['I', 'J', 'F'], [[248, 3], [251, 0]]), [[3, [], []], [4, [], []]]),
('chop more locals than exist', ([], [[250, 3]]), ['ClassFormatError', 0]),
('append three locals then snapshot',
(['I', 'Object'], [[0], [254, 3, 'I', 'I', 'F'], [0]]),
[[0, ['I', 'Object'], []],
[4, ['I', 'Object', 'I', 'I', 'F'], []],
[5, ['I', 'Object', 'I', 'I', 'F'], []]]),
('control: full frame replaces locals',
(['I', 'Object'], [[255, 3, ['Object'], []], [2]]),
[[3, ['Object'], []], [6, ['Object'], []]])],
[('regression: every compressed frame kind',
(['I', 'Object'], [[5], [74, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
[[5, ['I', 'Object'], []],
[16, ['I', 'Object'], ['I']],
[20, ['I', 'Object', 'F'], []],
[23, ['I'], []],
[324, ['I'], []],
[326, ['I'], ['Object', 'J']]]),
('first frame offset is its delta',
(['I', 'Object'], [[14], [3]]),
[[14, ['I', 'Object'], []], [18, ['I', 'Object'], []]]),
('same_locals_1_stack_item delta',
(['I', 'Object'], [[68, 'Object'], [64, 'I']]),
[[4, ['I', 'Object'], ['Object']], [5, ['I', 'Object'], ['I']]]),
('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
('extended one-item frame type',
(['I', 'Object'], [[247, 8, 'Object']]),
[[8, ['I', 'Object'], ['Object']]]),
('chop three locals', (['I', 'J', 'F'], [[248, 4], [251, 0]]), [[4, [], []], [5, [], []]]),
('chop more locals than exist', ([], [[250, 4]]), ['ClassFormatError', 0]),
('append three locals then snapshot',
(['I', 'Object'], [[0], [254, 4, 'I', 'I', 'F'], [0]]),
[[0, ['I', 'Object'], []],
[5, ['I', 'Object', 'I', 'I', 'F'], []],
[6, ['I', 'Object', 'I', 'I', 'F'], []]]),
('control: full frame replaces locals',
(['I', 'Object'], [[255, 4, ['Object'], []], [2]]),
[[4, ['Object'], []], [7, ['Object'], []]])],
[('regression: every compressed frame kind',
(['I', 'Object'], [[5], [75, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
[[5, ['I', 'Object'], []],
[17, ['I', 'Object'], ['I']],
[21, ['I', 'Object', 'F'], []],
[24, ['I'], []],
[325, ['I'], []],
[327, ['I'], ['Object', 'J']]]),
('first frame offset is its delta',
(['I', 'Object'], [[15], [3]]),
[[15, ['I', 'Object'], []], [19, ['I', 'Object'], []]]),
('same_locals_1_stack_item delta',
(['I', 'Object'], [[69, 'Object'], [64, 'I']]),
[[5, ['I', 'Object'], ['Object']], [6, ['I', 'Object'], ['I']]]),
('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
('extended one-item frame type',
(['I', 'Object'], [[247, 9, 'Object']]),
[[9, ['I', 'Object'], ['Object']]]),
('chop three locals', (['I', 'J', 'F'], [[248, 5], [251, 0]]), [[5, [], []], [6, [], []]]),
('chop more locals than exist', ([], [[250, 5]]), ['ClassFormatError', 0]),
('append three locals then snapshot',
(['I', 'Object'], [[0], [254, 5, 'I', 'I', 'F'], [0]]),
[[0, ['I', 'Object'], []],
[6, ['I', 'Object', 'I', 'I', 'F'], []],
[7, ['I', 'Object', 'I', 'I', 'F'], []]]),
('control: full frame replaces locals',
(['I', 'Object'], [[255, 5, ['Object'], []], [2]]),
[[5, ['Object'], []], [8, ['Object'], []]])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: every compressed frame kind | [[5, ['I', 'Object'], []], [12, ['I', 'Object'], ['I']], [15, ['I', 'Object', 'F'], []], [17, ['I'], []], [317, ['I'], []], [318, ['I'], ['Object', 'J']]] | [[5, ['I', 'Object'], []], [13, ['I', 'Object'], ['I']], [17, ['I', 'Object', 'F'], []], [20, ['I'], []], [321, ['I'], []], [323, ['I'], ['Object', 'J']]] | Failed |
| first frame offset is its delta | [[11, ['I', 'Object'], []], [14, ['I', 'Object'], []]] | [[11, ['I', 'Object'], []], [15, ['I', 'Object'], []]] | Failed |
| same_locals_1_stack_item delta | [[1, ['I', 'Object'], ['Object']], [1, ['I', 'Object'], ['I']]] | [[1, ['I', 'Object'], ['Object']], [2, ['I', 'Object'], ['I']]] | Failed |
| reserved frame type | ['ClassFormatError', 1] | ['ClassFormatError', 1] | Passed |
| extended one-item frame type | [[5, ['I', 'Object'], ['Object']]] | [[5, ['I', 'Object'], ['Object']]] | Passed |
| chop three locals | [[1, [], []], [1, [], []]] | [[1, [], []], [2, [], []]] | Failed |
| chop more locals than exist | ['ClassFormatError', 0] | ['ClassFormatError', 0] | Passed |
| append three locals then snapshot | [[0, ['I', 'Object'], []], [1, ['I', 'Object', 'I', 'I', 'F'], []], [1, ['I', 'Object', 'I', 'I', 'F'], []]] | [[0, ['I', 'Object'], []], [2, ['I', 'Object', 'I', 'I', 'F'], []], [3, ['I', 'Object', 'I', 'I', 'F'], []]] | Failed |
| control: full frame replaces locals | [[1, ['Object'], []], [3, ['Object'], []]] | [[1, ['Object'], []], [4, ['Object'], []]] | Failed |
SHA-256 / ae52960b83fb699083b689894231d910008d0f4486e4a0257c591d4883f841b0
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(initial, frames):
locals_ = list(initial)
out = []
offset = 0
for idx, fr in enumerate(frames):
t = fr[0]
stack = []
if t <= 63:
delta = t
elif t <= 127:
delta = t - 64
stack = [fr[1]]
elif t < 247:
return ['ClassFormatError', idx]
elif t == 247:
delta = fr[1]
stack = [fr[2]]
elif t <= 250:
delta = fr[1]
k = 251 - t
if k > len(locals_):
return ['ClassFormatError', idx]
locals_ = locals_[:len(locals_) - k]
elif t == 251:
delta = fr[1]
elif t <= 254:
delta = fr[1]
locals_ = locals_ + list(fr[2:2 + t - 251])
else:
delta = fr[1]
locals_ = list(fr[2])
stack = list(fr[3])
offset = delta if idx == 0 else offset + delta + 1
out.append([offset, locals_, stack])
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: every compressed frame kind',
(['I', 'Object'], [[5], [71, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
[[5, ['I', 'Object'], []],
[13, ['I', 'Object'], ['I']],
[17, ['I', 'Object', 'F'], []],
[20, ['I'], []],
[321, ['I'], []],
[323, ['I'], ['Object', 'J']]]),
('first frame offset is its delta',
(['I', 'Object'], [[11], [3]]),
[[11, ['I', 'Object'], []], [15, ['I', 'Object'], []]]),
('same_locals_1_stack_item delta',
(['I', 'Object'], [[65, 'Object'], [64, 'I']]),
[[1, ['I', 'Object'], ['Object']], [2, ['I', 'Object'], ['I']]]),
('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
('extended one-item frame type',
(['I', 'Object'], [[247, 5, 'Object']]),
[[5, ['I', 'Object'], ['Object']]]),
('chop three locals', (['I', 'J', 'F'], [[248, 1], [251, 0]]), [[1, [], []], [2, [], []]]),
('chop more locals than exist', ([], [[250, 1]]), ['ClassFormatError', 0]),
('append three locals then snapshot',
(['I', 'Object'], [[0], [254, 1, 'I', 'I', 'F'], [0]]),
[[0, ['I', 'Object'], []],
[2, ['I', 'Object', 'I', 'I', 'F'], []],
[3, ['I', 'Object', 'I', 'I', 'F'], []]]),
('control: full frame replaces locals',
(['I', 'Object'], [[255, 1, ['Object'], []], [2]]),
[[1, ['Object'], []], [4, ['Object'], []]])],
[('regression: every compressed frame kind',
(['I', 'Object'], [[5], [72, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
[[5, ['I', 'Object'], []],
[14, ['I', 'Object'], ['I']],
[18, ['I', 'Object', 'F'], []],
[21, ['I'], []],
[322, ['I'], []],
[324, ['I'], ['Object', 'J']]]),
('first frame offset is its delta',
(['I', 'Object'], [[12], [3]]),
[[12, ['I', 'Object'], []], [16, ['I', 'Object'], []]]),
('same_locals_1_stack_item delta',
(['I', 'Object'], [[66, 'Object'], [64, 'I']]),
[[2, ['I', 'Object'], ['Object']], [3, ['I', 'Object'], ['I']]]),
('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
('extended one-item frame type',
(['I', 'Object'], [[247, 6, 'Object']]),
[[6, ['I', 'Object'], ['Object']]]),
('chop three locals', (['I', 'J', 'F'], [[248, 2], [251, 0]]), [[2, [], []], [3, [], []]]),
('chop more locals than exist', ([], [[250, 2]]), ['ClassFormatError', 0]),
('append three locals then snapshot',
(['I', 'Object'], [[0], [254, 2, 'I', 'I', 'F'], [0]]),
[[0, ['I', 'Object'], []],
[3, ['I', 'Object', 'I', 'I', 'F'], []],
[4, ['I', 'Object', 'I', 'I', 'F'], []]]),
('control: full frame replaces locals',
(['I', 'Object'], [[255, 2, ['Object'], []], [2]]),
[[2, ['Object'], []], [5, ['Object'], []]])],
[('regression: every compressed frame kind',
(['I', 'Object'], [[5], [73, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
[[5, ['I', 'Object'], []],
[15, ['I', 'Object'], ['I']],
[19, ['I', 'Object', 'F'], []],
[22, ['I'], []],
[323, ['I'], []],
[325, ['I'], ['Object', 'J']]]),
('first frame offset is its delta',
(['I', 'Object'], [[13], [3]]),
[[13, ['I', 'Object'], []], [17, ['I', 'Object'], []]]),
('same_locals_1_stack_item delta',
(['I', 'Object'], [[67, 'Object'], [64, 'I']]),
[[3, ['I', 'Object'], ['Object']], [4, ['I', 'Object'], ['I']]]),
('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
('extended one-item frame type',
(['I', 'Object'], [[247, 7, 'Object']]),
[[7, ['I', 'Object'], ['Object']]]),
('chop three locals', (['I', 'J', 'F'], [[248, 3], [251, 0]]), [[3, [], []], [4, [], []]]),
('chop more locals than exist', ([], [[250, 3]]), ['ClassFormatError', 0]),
('append three locals then snapshot',
(['I', 'Object'], [[0], [254, 3, 'I', 'I', 'F'], [0]]),
[[0, ['I', 'Object'], []],
[4, ['I', 'Object', 'I', 'I', 'F'], []],
[5, ['I', 'Object', 'I', 'I', 'F'], []]]),
('control: full frame replaces locals',
(['I', 'Object'], [[255, 3, ['Object'], []], [2]]),
[[3, ['Object'], []], [6, ['Object'], []]])],
[('regression: every compressed frame kind',
(['I', 'Object'], [[5], [74, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
[[5, ['I', 'Object'], []],
[16, ['I', 'Object'], ['I']],
[20, ['I', 'Object', 'F'], []],
[23, ['I'], []],
[324, ['I'], []],
[326, ['I'], ['Object', 'J']]]),
('first frame offset is its delta',
(['I', 'Object'], [[14], [3]]),
[[14, ['I', 'Object'], []], [18, ['I', 'Object'], []]]),
('same_locals_1_stack_item delta',
(['I', 'Object'], [[68, 'Object'], [64, 'I']]),
[[4, ['I', 'Object'], ['Object']], [5, ['I', 'Object'], ['I']]]),
('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
('extended one-item frame type',
(['I', 'Object'], [[247, 8, 'Object']]),
[[8, ['I', 'Object'], ['Object']]]),
('chop three locals', (['I', 'J', 'F'], [[248, 4], [251, 0]]), [[4, [], []], [5, [], []]]),
('chop more locals than exist', ([], [[250, 4]]), ['ClassFormatError', 0]),
('append three locals then snapshot',
(['I', 'Object'], [[0], [254, 4, 'I', 'I', 'F'], [0]]),
[[0, ['I', 'Object'], []],
[5, ['I', 'Object', 'I', 'I', 'F'], []],
[6, ['I', 'Object', 'I', 'I', 'F'], []]]),
('control: full frame replaces locals',
(['I', 'Object'], [[255, 4, ['Object'], []], [2]]),
[[4, ['Object'], []], [7, ['Object'], []]])],
[('regression: every compressed frame kind',
(['I', 'Object'], [[5], [75, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
[[5, ['I', 'Object'], []],
[17, ['I', 'Object'], ['I']],
[21, ['I', 'Object', 'F'], []],
[24, ['I'], []],
[325, ['I'], []],
[327, ['I'], ['Object', 'J']]]),
('first frame offset is its delta',
(['I', 'Object'], [[15], [3]]),
[[15, ['I', 'Object'], []], [19, ['I', 'Object'], []]]),
('same_locals_1_stack_item delta',
(['I', 'Object'], [[69, 'Object'], [64, 'I']]),
[[5, ['I', 'Object'], ['Object']], [6, ['I', 'Object'], ['I']]]),
('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
('extended one-item frame type',
(['I', 'Object'], [[247, 9, 'Object']]),
[[9, ['I', 'Object'], ['Object']]]),
('chop three locals', (['I', 'J', 'F'], [[248, 5], [251, 0]]), [[5, [], []], [6, [], []]]),
('chop more locals than exist', ([], [[250, 5]]), ['ClassFormatError', 0]),
('append three locals then snapshot',
(['I', 'Object'], [[0], [254, 5, 'I', 'I', 'F'], [0]]),
[[0, ['I', 'Object'], []],
[6, ['I', 'Object', 'I', 'I', 'F'], []],
[7, ['I', 'Object', 'I', 'I', 'F'], []]]),
('control: full frame replaces locals',
(['I', 'Object'], [[255, 5, ['Object'], []], [2]]),
[[5, ['Object'], []], [8, ['Object'], []]])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: every compressed frame kind | [[5, ['I', 'Object'], []], [13, ['I', 'Object'], ['I']], [17, ['I', 'Object', 'F'], []], [20, ['I'], []], [321, ['I'], []], [323, ['I'], ['Object', 'J']]] | [[5, ['I', 'Object'], []], [13, ['I', 'Object'], ['I']], [17, ['I', 'Object', 'F'], []], [20, ['I'], []], [321, ['I'], []], [323, ['I'], ['Object', 'J']]] | Passed |
| first frame offset is its delta | [[11, ['I', 'Object'], []], [15, ['I', 'Object'], []]] | [[11, ['I', 'Object'], []], [15, ['I', 'Object'], []]] | Passed |
| same_locals_1_stack_item delta | [[1, ['I', 'Object'], ['Object']], [2, ['I', 'Object'], ['I']]] | [[1, ['I', 'Object'], ['Object']], [2, ['I', 'Object'], ['I']]] | Passed |
| reserved frame type | ['ClassFormatError', 1] | ['ClassFormatError', 1] | Passed |
| extended one-item frame type | [[5, ['I', 'Object'], ['Object']]] | [[5, ['I', 'Object'], ['Object']]] | Passed |
| chop three locals | [[1, [], []], [2, [], []]] | [[1, [], []], [2, [], []]] | Passed |
| chop more locals than exist | ['ClassFormatError', 0] | ['ClassFormatError', 0] | Passed |
| append three locals then snapshot | [[0, ['I', 'Object'], []], [2, ['I', 'Object', 'I', 'I', 'F'], []], [3, ['I', 'Object', 'I', 'I', 'F'], []]] | [[0, ['I', 'Object'], []], [2, ['I', 'Object', 'I', 'I', 'F'], []], [3, ['I', 'Object', 'I', 'I', 'F'], []]] | Passed |
| control: full frame replaces locals | [[1, ['Object'], []], [4, ['Object'], []]] | [[1, ['Object'], []], [4, ['Object'], []]] | Passed |
SHA-256 / a1e4f2597be70b86de5251cdab6fe6ae3a4f73edc84db53cdecc2e859bfe058a
Verification & scope
A deterministic, bounded teaching model of one bytecode virtual machine mechanism with a stipulated instruction encoding; it is not a production VM and claims no conformance to any real specification. 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:25.501821+00:00.
Case digest / 0b7a0950d34771e8e7884e917b79afa5845a37618b53fe6ff0670106234fd721