Skip to content

Pack a native-endian directive as the machine actually packs it - #431

Merged
tannevaled merged 1 commit into
mainfrom
fix/pack-native-endian
Aug 23, 2026
Merged

tannevaled merged 1 commit into
mainfrom
fix/pack-native-endian

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

arch-qemu-nightly has been red every night since 2026-08-07 — seventeen nights — and the s390x job's whole failure is nine subtests of TestPackUnpack / TestPackUnpackModifiers:

--- FAIL: TestPackUnpack/pack_S   got="[1, 2]"                       want="[2, 1]"
--- FAIL: TestPackUnpack/pack_L   got="[1, 2, 3, 4]"                 want="[4, 3, 2, 1]"
--- FAIL: TestPackUnpack/pack_Q   got="[0, 0, 0, 0, 0, 0, 0, 1]"     want="[1, 0, 0, 0, 0, 0, 0, 0]"
--- FAIL: TestPackUnpack/pack_f   got="[63, 192, 0, 0]"              want="[0, 0, 192, 63]"
--- FAIL: TestPackUnpack/pack_d   got="[63, 248, 0, 0, 0, 0, 0, 0]"  want="[0, 0, 0, 0, 0, 0, 248, 63]"
… and pack_s, pack_F_alias, pack_D_alias, pack_i

The implementation is right and the test was wrong. S/s, L/l, I/i, Q/q, J/j and f/F/d/D are native-endian by definition — that is what MRI does too — so an expectation written out in one byte order is an expectation that only holds on half the architectures. It held here because the machines that ran it were all little-endian.

native(le, be) picks the expectation from what the running binary actually stores (binary.NativeEndian), so both halves assert the real bytes instead of one half asserting nothing.

The explicitly-ordered directives — n, N, v, V, e, E, g, G and the < > modifiers — are untouched and keep their literal bytes, which is the entire point of them.

Proof

  • go test ./internal/vm/ -run TestPackUnpack green here (little-endian), full ./internal/vm/ green.
  • Little-endian correctness is not weakened: on this machine native returns the same literals the file asserted before.
  • The claim that matters is big-endian, and this machine cannot make it. arch-qemu-nightly is dispatched on this branch — the s390x job is the lane that would catch it, and its result is linked in a comment below before this merges.

S/s, L/l, I/i, Q/q, J/j and f/F/d/D are native-endian by definition, so
the byte content this suite asserted was an expectation that only ever
held on half the architectures. The nightly runs on s390x, which is the
other half, and has been red every night since 2026-08-07 on exactly the
nine subtests this touches.

The implementation was right all along: it packs in the host's order,
which is what MRI does. The test asked it to be little-endian.

`native(le, be)` picks the expectation by what the running binary
actually stores, so both halves assert the real thing rather than one
half asserting nothing. The explicitly-ordered directives — n, N, v, V,
e, E, g, G and the < > modifiers — are untouched and keep their literal
bytes, which is the point of them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tannevaled

Copy link
Copy Markdown
Contributor Author

Verified on the lane that catches it. This machine is little-endian and cannot make the claim, so both this and #432 were put on verify/arch-nightly and arch-qemu-nightly was dispatched on it — one run for the two, because the workflow has a global concurrency group with cancel-in-progress and two dispatches would cancel each other.

Run 32661057000 — all four green, after seventeen consecutive red nights:

success  arch s390x (qemu)      ok  …/internal/vm  1753.983s
success  arch loong64 (qemu)    ok  …/internal/vm   990.692s
success  arch riscv64 (qemu)
success  arch ppc64le (qemu)

Not a green tick taken on trust: the s390x log has 0 --- FAIL lines and 0 --- SKIP lines, the step is go test -timeout=30m -exec=qemu-s390x-static ./... with no -run filter, and the package took 1754s — the same order as the runs that were failing, so it ran the suite rather than skipping it.

@tannevaled
tannevaled merged commit 152f1c9 into main Aug 23, 2026
7 checks passed
@tannevaled
tannevaled deleted the fix/pack-native-endian branch August 24, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant