20. The section table was one slot short, and the padding was never padding¶
The container parser had an off by one from the first day it existed, in both implementations, and every consistency check passed anyway. This section is the correction and, more usefully, why nothing caught it.
What the parser believed¶
The header was read as twelve bytes, then a table of N four byte pointers at 0x0C, then three
zero bytes of padding, then the four letter marker. N was derived, because the header does not
state it:
N = (marker_offset - 3 - 0x0C) / 4
That gave 19 on arch 9 and 14, 20 on arch 8, 21 on arch 12, and it reproduced the measured marker
offset on all thirteen samples. The - 3 was the padding. Nobody could say why a format that
derives everything else would need exactly three bytes of it, and docs/config-format.md carried
an explicit ambiguity next to the formula: a trailing NULL pointer and extra padding are
indistinguishable, so 19 pointers plus seven zero bytes reads the same as 20 pointers plus three.
The document said so rather than picking silently, and tests/test_gspm.py had a class named
TestPointerTablePaddingAmbiguity pinning the consequence.
What it actually is¶
The table starts at 0x0B, and an item is four bytes made of a spare byte and a three byte
little endian address:
0x0B { u8 spare; u24 address }[N]
The addresses therefore still land on 0x0C, 0x10, 0x14, which is why every address the old
parser reported was correct. What it lacked was the last item, whose address occupies the three
bytes immediately before the marker. Those are the three bytes the old formula subtracted as
padding.
So N is one higher on every architecture: 20 on arch 9 and 14, 21 on arch 8, 22 on arch 12.
What closes it¶
Arithmetic on the whole corpus, and it closes in a way the old reading cannot match:
0x0B + 4 * N == marker_offset exactly, thirteen samples, four architectures
No remainder. The old reading had to subtract three bytes to make its own arithmetic meet the marker, and could not say what they were. This one meets it with nothing left over, which is the same kind of closure as the IR carrier finding in section 12: the numbers land on each other rather than merely near each other.
Two further checks agree. Reading an address at 0x0B + 4k instead of 0x0C + 4k gives values
far outside the blob, so the pointer is offset by one within the item and not the item by one
within the table. And the spare byte is zero in every section of every sample, which is
precisely why a four byte read of the item worked: the byte the fourth read consumed was the next
item's spare byte, always zero. The parsers now read three bytes and check the spare, because a
nonzero one would otherwise add 0x1000000 to an address and produce a plausible wrong answer
instead of an error.
Why every check passed¶
Because the missing slot is NULL in all thirteen samples. A NULL section is an absent section, so a parser that never knew about it decoded exactly the same configuration. In base slot terms the base layout is 20 slots whose last two, base 18 and base 19, are NULL on all four architectures. The old parser stopped after base 18.
That is the honest explanation of a bug living this long, and it is also the reason the fix
changes no decoded output: not one section address, length, action list or key record moves. The
spare field and one extra NULL section per container are the whole diff, plus regenerated golden
vectors that differ only by those.
The check that would have caught it¶
There now is one, and it is the derivation stated as a closure rather than as a subtraction:
section_table_ends_at_the_marker: 0x0B + 4 * N == marker_offset
The old code could not have run this check, since under its own reading the table stopped three bytes short of the marker by construction. A derivation with an unexplained constant in it was the warning, and the ambiguity written next to it was the second warning. Both were recorded honestly and neither was chased. The lesson is narrower than "check your arithmetic": an unexplained fudge factor in a derivation is a finding waiting to happen, and documenting it is not the same as resolving it.
tests/test_gspm.py class TestPointerTableLength and
packages/codec/test/gspm.test.ts hold this, in both implementations, over every sample.
Section 19 | the archive | section 21. Section 20 of the findings archive, which is frozen; the reference holds the current answer. The archive on GitHub.