Skip to content

Direct Pivco-Huffman port - #66

Open
Sanya239 wants to merge 1 commit into
mainfrom
feature/pivco-huffman
Open

Direct Pivco-Huffman port#66
Sanya239 wants to merge 1 commit into
mainfrom
feature/pivco-huffman

Conversation

@Sanya239

@Sanya239 Sanya239 commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@Sanya239
Sanya239 requested a review from Malkovsky September 1, 2026 23:06

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 56c4fa9598

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

blk_enc_len = get_u32(p); p += 4;
if (p + blk_enc_len > body_end) { err = PIVCOHUF_ERR_TOO_SHORT; break; }
blk_remaining = uncomp_size - written;
blk_out = (blk_remaining >= B) ? (out + written) : block_buf;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Validate each block's symbol count before decoding

When loading corrupted or attacker-controlled serialized bytes, the encoded block carries its own symbol count, but blk_out capacity is selected solely from the independent file-level B and uncompressed-size fields. For example, changing a valid 32,768-symbol stream's header to declare an uncompressed size and block size of 1 makes pivco_decode write the embedded 32,768 symbols into a one-byte vector; this produces an ASan-confirmed heap-buffer-overflow. Parse and validate the block's count against both the destination capacity and declared block size before decoding.

AGENTS.md reference: AGENTS.md:L86-L92

Useful? React with 👍 / 👎.

Comment thread cmake/PivCo.cmake
Comment on lines +37 to +44
list(APPEND PIXIE_PIVCO_DEFINITIONS
PIVCO_HAS_AVX2=1
PIVCO_HAS_SSE4=1)
list(APPEND PIXIE_PIVCO_OPTIONS
-mavx2
-mbmi2
-msse4.1
-mpopcnt)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Gate the x86 backend on the required CPU features

On every x86_64/amd64 build, this unconditionally defines the AVX2 backend and compiles all codec and common sources with AVX2, BMI2, SSE4.1, and POPCNT. Since pivco_encode and pivco_decode statically select the x86 worker whenever these definitions exist, binaries run on older x86-64 CPUs—or builds configured with PIXIE_DISABLE_BMI2=ON—can execute unsupported instructions instead of using the included scalar fallback. Detect the required features or honor the fallback options before enabling this tier.

AGENTS.md reference: AGENTS.md:L348-L353

Useful? React with 👍 / 👎.

Comment on lines +355 to +356
/* HEADER_CHECKSUM verification disabled (2026-05-12) -- bytes are
* still in the format at offset 22..25, currently always zero. */

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore checksum verification before exposing the codec

For any stream damaged in storage or transit, the decoder ignores both checksum fields even though the public pivcohuf_decompress contract says it verifies them and the wire-format documentation specifically relies on the header checksum to protect BODY_LENGTH. The encoder also writes zero checksums, so corruption can silently produce incorrect output or feed corrupted metadata into unsafe length arithmetic rather than returning a checksum error.

AGENTS.md reference: AGENTS.md:L86-L92

Useful? React with 👍 / 👎.

Comment thread cmake/PivCo.cmake
Comment on lines +110 to +111
target_compile_options(${codec_target}
PRIVATE -O3 ${PIXIE_PIVCO_OPTIONS})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Instrument the new C backend in the ASan preset

When the repository's asan preset is used, ENABLE_ADDRESS_SANITIZER adds sanitizer flags only to CMAKE_CXX_FLAGS; these newly added .c targets therefore compile without -fsanitize=address and are additionally forced to -O3. As a result, memory errors inside the codec—including out-of-bounds SIMD stores—are not checked by the fallback validation job even though the C++ test executable links ASan. Apply the sanitizer settings to the C targets as well.

AGENTS.md reference: AGENTS.md:L356-L357

Useful? React with 👍 / 👎.

@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.67%. Comparing base (2a43cde) to head (56c4fa9).

Files with missing lines Patch % Lines
include/pixie/huffman/pivco_huffman.h 87.17% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #66      +/-   ##
==========================================
+ Coverage   90.66%   90.67%   +0.01%     
==========================================
  Files          47       50       +3     
  Lines       12220    12290      +70     
  Branches     1771     1778       +7     
==========================================
+ Hits        11079    11144      +65     
- Misses        533      536       +3     
- Partials      608      610       +2     
Flag Coverage Δ
gcov 90.67% <92.85%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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