Skip to content

fix(ipc): Zero the padding of footer Blocks - #986

Open
pedrobtz wants to merge 1 commit into
apache:mainfrom
pedrobtz:fix-ipc-footer-block-padding
Open

pedrobtz wants to merge 1 commit into
apache:mainfrom
pedrobtz:fix-ipc-footer-block-padding

Conversation

@pedrobtz

Copy link
Copy Markdown

ArrowIpcEncoderEncodeFooter() builds each Block of the footer on the stack with an initializer, then copies it into the flatbuffer vector. Block has four bytes of padding after metaDataLength, and an initializer doesn't set padding. So the footer carried whatever bytes were on the stack. That makes files non-reproducible, and the stack bytes end up in the file. With Apple clang 17 at -O0, filling the stack with 0xAB before the call gives padding abababab.

The vector is now zeroed after extend, and each element is set with the generated Block_assign(). Both the record batch and the dictionary block loops are changed.

The new NanoarrowIpcFooterEncodingIsDeterministic test encodes the same footer twice, after filling the stack with 0x00 and then 0xFF, and requires identical bytes. In a plain Debug build it fails without the fix and passes with it. Under ASan it passes either way, because ASan moves stack frames.

Found through a byte-for-byte determinism test in the zuarrow R package, which vendors nanoarrow.

ctest passes in a plain Debug build and with ASan and UBSan (410 tests each). The changed files are formatted with the pinned clang-format 16.0.6.

🤖 Generated with Claude Code

Each Block was built on the stack with an initializer and copied into the
footer, so its four bytes of padding after metaDataLength were whatever
was on the stack. Zero the vector and set each field instead.

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

This branch has not been deployed

No deployments
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