FAILURE MAP
← Case archive

FA-71846 / Error-correcting codes / Open access

Hamming syndrome adds positions arithmetically · case 01

Clean codewords report nonzero syndromes and get corrupted.

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

ROOT CAUSE

Positions are accumulated with += instead of XOR.

THE FAILURE

Positions are accumulated with += instead of XOR.

Unsuccessful approach: Accumulating with bitwise OR cannot cancel paired contributions either.

Case contract

Single-error-correcting Hamming decoder for a full or shortened code of length n >= 3 (bits 0/1, else None). Positions are 1-based; parity bits sit at powers of two. The syndrome is the XOR of the positions holding a 1. A syndrome above n points outside the shortened code and is "uncorrectable" (data None); otherwise the bit at the syndrome position is flipped. Return [status, data bits from non-power-of-two positions, syndrome].

Why this case matters

Memory and link controllers use (shortened) Hamming codes to repair single-bit upsets.

1 / The failure

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

N = 1
observations = []
def solve(r):
    n = len(r)
    if n < 3 or any(b not in (0, 1) for b in r):
        return None
    s = 0
    for pos in range(1, n + 1):
        if r[pos - 1]:
            s += pos
    if s > n:
        return ['uncorrectable', None, s]
    c = list(r)
    if s:
        c[s - 1] ^= 1
    data = [c[pos - 1] for pos in range(1, n + 1) if pos & (pos - 1)]
    return ['corrected' if s else 'clean', data, s]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression [[0, 1, 1, 0, 1, 1, 1]]', [[0, 1, 1, 0, 1, 1, 1]], ['corrected', [1, 0, 1, 1], 5]], ['regression [[0, 1, 1, 0, 0, 1, 1]]', [[0, 1, 1, 0, 0, 1, 1]], ['clean', [1, 0, 1, 1], 0]], ['control [[1, 0, 0, 0, 0, 1, 0]]', [[1, 0, 0, 0, 0, 1, 0]], ['corrected', [0, 0, 1, 1], 7]], ['control [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]]', [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]], ['corrected', [1, 0, 0, 1, 0, 0], 7]], ['control [[1, 0, 0, 0, 0, 0, 0, 1, 0]]', [[1, 0, 0, 0, 0, 0, 0, 1, 0]], ['corrected', [0, 0, 0, 0, 1], 9]], ['control [[0, 1]]', [[0, 1]], None], ['control [[0, 1, 2, 0, 0, 0, 0]]', [[0, 1, 2, 0, 0, 0, 0]], None], ['control [[1, 0, 0, 1, 0, 1, 0]]', [[1, 0, 0, 1, 0, 1, 0]], ['corrected', [1, 0, 1, 0], 3]]], [['regression [[1, 1, 0, 1, 0, 1, 0]]', [[1, 1, 0, 1, 0, 1, 0]], ['corrected', [0, 0, 1, 0], 1]], ['regression [[0, 1, 0, 1, 0, 1, 1]]', [[0, 1, 0, 1, 0, 1, 1]], ['corrected', [0, 0, 1, 0], 7]], ['partial-repair [[1, 0, 0, 1, 0, 1, 0]]', [[1, 0, 0, 1, 0, 1, 0]], ['corrected', [1, 0, 1, 0], 3]], ['control [[1, 0, 0, 0, 0, 1, 0]]', [[1, 0, 0, 0, 0, 1, 0]], ['corrected', [0, 0, 1, 1], 7]], ['control [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]]', [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]], ['corrected', [1, 0, 0, 1, 0, 0], 7]], ['control [[1, 0, 0, 0, 0, 0, 0, 1, 0]]', [[1, 0, 0, 0, 0, 0, 0, 1, 0]], ['corrected', [0, 0, 0, 0, 1], 9]], ['control [[0, 1]]', [[0, 1]], None], ['control [[0, 1, 2, 0, 0, 0, 0]]', [[0, 1, 2, 0, 0, 0, 0]], None]], [['regression [[0, 1, 1, 1, 0, 1, 0]]', [[0, 1, 1, 1, 0, 1, 0]], ['corrected', [0, 0, 1, 0], 3]], ['regression [[1, 0, 0, 0, 0, 1, 1]]', [[1, 0, 0, 0, 0, 1, 1]], ['clean', [0, 0, 1, 1], 0]], ['partial-repair [[1, 0, 0, 0, 1, 1, 1]]', [[1, 0, 0, 0, 1, 1, 1]], ['corrected', [0, 0, 1, 1], 5]], ['control [[1, 0, 0, 0, 0, 1, 0]]', [[1, 0, 0, 0, 0, 1, 0]], ['corrected', [0, 0, 1, 1], 7]], ['control [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]]', [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]], ['corrected', [1, 0, 0, 1, 0, 0], 7]], ['control [[1, 0, 0, 0, 0, 0, 0, 1, 0]]', [[1, 0, 0, 0, 0, 0, 0, 1, 0]], ['corrected', [0, 0, 0, 0, 1], 9]], ['control [[0, 1]]', [[0, 1]], None], ['control [[0, 1, 2, 0, 0, 0, 0]]', [[0, 1, 2, 0, 0, 0, 0]], None]], [['regression [[0, 1, 0, 0, 0, 1, 1]]', [[0, 1, 0, 0, 0, 1, 1]], ['corrected', [1, 0, 1, 1], 3]], ['regression [[1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0]]', [[1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0]], ['clean', [0, 1, 1, 0, 1, 1, 1, 0], 0]], ['partial-repair [[1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0]]', [[1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0]], ['corrected', [0, 1, 1, 0, 1, 1, 1, 0], 4]], ['control [[1, 0, 0, 0, 0, 1, 0]]', [[1, 0, 0, 0, 0, 1, 0]], ['corrected', [0, 0, 1, 1], 7]], ['control [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]]', [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]], ['corrected', [1, 0, 0, 1, 0, 0], 7]], ['control [[1, 0, 0, 0, 0, 0, 0, 1, 0]]', [[1, 0, 0, 0, 0, 0, 0, 1, 0]], ['corrected', [0, 0, 0, 0, 1], 9]], ['control [[0, 1]]', [[0, 1]], None], ['control [[0, 1, 2, 0, 0, 0, 0]]', [[0, 1, 2, 0, 0, 0, 0]], None]], [['regression [[1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1]]', [[1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1]], ['corrected', [0, 1, 1, 0, 1, 1, 1, 0], 12]], ['regression [[1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0]]', [[1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0]], ['clean', [0, 1, 0, 0, 1, 1, 1, 0], 0]], ['partial-repair [[1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0]]', [[1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0]], ['corrected', [0, 1, 0, 0, 1, 1, 1, 0], 8]], ['control [[1, 0, 0, 0, 0, 1, 0]]', [[1, 0, 0, 0, 0, 1, 0]], ['corrected', [0, 0, 1, 1], 7]], ['control [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]]', [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]], ['corrected', [1, 0, 0, 1, 0, 0], 7]], ['control [[1, 0, 0, 0, 0, 0, 0, 1, 0]]', [[1, 0, 0, 0, 0, 0, 0, 1, 0]], ['corrected', [0, 0, 0, 0, 1], 9]], ['control [[0, 1]]', [[0, 1]], None], ['control [[0, 1, 2, 0, 0, 0, 0]]', [[0, 1, 2, 0, 0, 0, 0]], None]]]
for label, args, expected in fixtures[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 [[0, 1, 1, 0, 1, 1, 1]]['uncorrectable', None, 23]['corrected', [1, 0, 1, 1], 5]Failed
regression [[0, 1, 1, 0, 0, 1, 1]]['uncorrectable', None, 18]['clean', [1, 0, 1, 1], 0]Failed
control [[1, 0, 0, 0, 0, 1, 0]]['corrected', [0, 0, 1, 1], 7]['corrected', [0, 0, 1, 1], 7]Passed
control [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]]['corrected', [1, 0, 0, 1, 0, 0], 7]['corrected', [1, 0, 0, 1, 0, 0], 7]Passed
control [[1, 0, 0, 0, 0, 0, 0, 1, 0]]['corrected', [0, 0, 0, 0, 1], 9]['corrected', [0, 0, 0, 0, 1], 9]Passed
control [[0, 1]]NoneNonePassed
control [[0, 1, 2, 0, 0, 0, 0]]NoneNonePassed
control [[1, 0, 0, 1, 0, 1, 0]]['uncorrectable', None, 11]['corrected', [1, 0, 1, 0], 3]Failed

SHA-256 / 44bbb7be4e99f51cf54725e3f26d0be68440b512891a04774feaf2a4b7f20c3d

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(r):
    n = len(r)
    if n < 3 or any(b not in (0, 1) for b in r):
        return None
    s = 0
    for pos in range(1, n + 1):
        if r[pos - 1]:
            s |= pos
    if s > n:
        return ['uncorrectable', None, s]
    c = list(r)
    if s:
        c[s - 1] ^= 1
    data = [c[pos - 1] for pos in range(1, n + 1) if pos & (pos - 1)]
    return ['corrected' if s else 'clean', data, s]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression [[0, 1, 1, 0, 1, 1, 1]]', [[0, 1, 1, 0, 1, 1, 1]], ['corrected', [1, 0, 1, 1], 5]], ['regression [[0, 1, 1, 0, 0, 1, 1]]', [[0, 1, 1, 0, 0, 1, 1]], ['clean', [1, 0, 1, 1], 0]], ['control [[1, 0, 0, 0, 0, 1, 0]]', [[1, 0, 0, 0, 0, 1, 0]], ['corrected', [0, 0, 1, 1], 7]], ['control [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]]', [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]], ['corrected', [1, 0, 0, 1, 0, 0], 7]], ['control [[1, 0, 0, 0, 0, 0, 0, 1, 0]]', [[1, 0, 0, 0, 0, 0, 0, 1, 0]], ['corrected', [0, 0, 0, 0, 1], 9]], ['control [[0, 1]]', [[0, 1]], None], ['control [[0, 1, 2, 0, 0, 0, 0]]', [[0, 1, 2, 0, 0, 0, 0]], None], ['control [[1, 0, 0, 1, 0, 1, 0]]', [[1, 0, 0, 1, 0, 1, 0]], ['corrected', [1, 0, 1, 0], 3]]], [['regression [[1, 1, 0, 1, 0, 1, 0]]', [[1, 1, 0, 1, 0, 1, 0]], ['corrected', [0, 0, 1, 0], 1]], ['regression [[0, 1, 0, 1, 0, 1, 1]]', [[0, 1, 0, 1, 0, 1, 1]], ['corrected', [0, 0, 1, 0], 7]], ['partial-repair [[1, 0, 0, 1, 0, 1, 0]]', [[1, 0, 0, 1, 0, 1, 0]], ['corrected', [1, 0, 1, 0], 3]], ['control [[1, 0, 0, 0, 0, 1, 0]]', [[1, 0, 0, 0, 0, 1, 0]], ['corrected', [0, 0, 1, 1], 7]], ['control [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]]', [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]], ['corrected', [1, 0, 0, 1, 0, 0], 7]], ['control [[1, 0, 0, 0, 0, 0, 0, 1, 0]]', [[1, 0, 0, 0, 0, 0, 0, 1, 0]], ['corrected', [0, 0, 0, 0, 1], 9]], ['control [[0, 1]]', [[0, 1]], None], ['control [[0, 1, 2, 0, 0, 0, 0]]', [[0, 1, 2, 0, 0, 0, 0]], None]], [['regression [[0, 1, 1, 1, 0, 1, 0]]', [[0, 1, 1, 1, 0, 1, 0]], ['corrected', [0, 0, 1, 0], 3]], ['regression [[1, 0, 0, 0, 0, 1, 1]]', [[1, 0, 0, 0, 0, 1, 1]], ['clean', [0, 0, 1, 1], 0]], ['partial-repair [[1, 0, 0, 0, 1, 1, 1]]', [[1, 0, 0, 0, 1, 1, 1]], ['corrected', [0, 0, 1, 1], 5]], ['control [[1, 0, 0, 0, 0, 1, 0]]', [[1, 0, 0, 0, 0, 1, 0]], ['corrected', [0, 0, 1, 1], 7]], ['control [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]]', [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]], ['corrected', [1, 0, 0, 1, 0, 0], 7]], ['control [[1, 0, 0, 0, 0, 0, 0, 1, 0]]', [[1, 0, 0, 0, 0, 0, 0, 1, 0]], ['corrected', [0, 0, 0, 0, 1], 9]], ['control [[0, 1]]', [[0, 1]], None], ['control [[0, 1, 2, 0, 0, 0, 0]]', [[0, 1, 2, 0, 0, 0, 0]], None]], [['regression [[0, 1, 0, 0, 0, 1, 1]]', [[0, 1, 0, 0, 0, 1, 1]], ['corrected', [1, 0, 1, 1], 3]], ['regression [[1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0]]', [[1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0]], ['clean', [0, 1, 1, 0, 1, 1, 1, 0], 0]], ['partial-repair [[1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0]]', [[1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0]], ['corrected', [0, 1, 1, 0, 1, 1, 1, 0], 4]], ['control [[1, 0, 0, 0, 0, 1, 0]]', [[1, 0, 0, 0, 0, 1, 0]], ['corrected', [0, 0, 1, 1], 7]], ['control [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]]', [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]], ['corrected', [1, 0, 0, 1, 0, 0], 7]], ['control [[1, 0, 0, 0, 0, 0, 0, 1, 0]]', [[1, 0, 0, 0, 0, 0, 0, 1, 0]], ['corrected', [0, 0, 0, 0, 1], 9]], ['control [[0, 1]]', [[0, 1]], None], ['control [[0, 1, 2, 0, 0, 0, 0]]', [[0, 1, 2, 0, 0, 0, 0]], None]], [['regression [[1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1]]', [[1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1]], ['corrected', [0, 1, 1, 0, 1, 1, 1, 0], 12]], ['regression [[1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0]]', [[1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0]], ['clean', [0, 1, 0, 0, 1, 1, 1, 0], 0]], ['partial-repair [[1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0]]', [[1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0]], ['corrected', [0, 1, 0, 0, 1, 1, 1, 0], 8]], ['control [[1, 0, 0, 0, 0, 1, 0]]', [[1, 0, 0, 0, 0, 1, 0]], ['corrected', [0, 0, 1, 1], 7]], ['control [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]]', [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]], ['corrected', [1, 0, 0, 1, 0, 0], 7]], ['control [[1, 0, 0, 0, 0, 0, 0, 1, 0]]', [[1, 0, 0, 0, 0, 0, 0, 1, 0]], ['corrected', [0, 0, 0, 0, 1], 9]], ['control [[0, 1]]', [[0, 1]], None], ['control [[0, 1, 2, 0, 0, 0, 0]]', [[0, 1, 2, 0, 0, 0, 0]], None]]]
for label, args, expected in fixtures[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 [[0, 1, 1, 0, 1, 1, 1]]['corrected', [1, 1, 1, 0], 7]['corrected', [1, 0, 1, 1], 5]Failed
regression [[0, 1, 1, 0, 0, 1, 1]]['corrected', [1, 0, 1, 0], 7]['clean', [1, 0, 1, 1], 0]Failed
control [[1, 0, 0, 0, 0, 1, 0]]['corrected', [0, 0, 1, 1], 7]['corrected', [0, 0, 1, 1], 7]Passed
control [[0, 0, 1, 1, 0, 0, 0, 0, 0, 0]]['corrected', [1, 0, 0, 1, 0, 0], 7]['corrected', [1, 0, 0, 1, 0, 0], 7]Passed
control [[1, 0, 0, 0, 0, 0, 0, 1, 0]]['corrected', [0, 0, 0, 0, 1], 9]['corrected', [0, 0, 0, 0, 1], 9]Passed
control [[0, 1]]NoneNonePassed
control [[0, 1, 2, 0, 0, 0, 0]]NoneNonePassed
control [[1, 0, 0, 1, 0, 1, 0]]['corrected', [0, 0, 1, 1], 7]['corrected', [1, 0, 1, 0], 3]Failed

SHA-256 / 0fdcd95189ce63f5f1e183db0cc76040741bafee42eab093c97f72f3ec7e1a4a

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

Verification & scope

A deterministic, bounded teaching model of the named code under the stated contract; not a production codec. 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:48:33.287327+00:00.

Case digest / 7b349dcbf9b6c04ae5f71ecce4ee6d2345461538d958acbe313cb6225e7d4eb7