← Back to Pull requests

Upgrade SZ3 to v3.4.0; bound the header parse in decompress_config #16

Open
unknown opened this pull request with 398 lines diff across 4 files
View on GitHub
unknown unknown commented on Sep 16, 2026 23:15 UTC
Author

Upgrades SZ3 to v3.4.0 and bounds the header and trailer parse in decompress_config, and passes SZ3's errors to Rust. Five commits.

1. Bound the header parse (fd536d8)

decompress_config read cmpDataSize out of the buffer and stepped over it unchecked, so a corrupted or truncated stream sent cmpConfPos past the end of the allocation (ASan: heap-buffer-overflow in SZ3::read, reproduced against the pinned c9a428b2 with a 32-byte buffer declaring a 1000-byte payload). It now checks that the buffer holds a header and that the declared payload fits.

2. Upgrade SZ3 to v3.4.0 (bee8b09)

  • sz3-sys/SZ3 to v3.4.0 (592df79); sz3 and sz3-sys to 0.5.0+SZ3-3.4.0.

  • decompress_config passes Config::load the bytes left after the payload. 3.4.0 requires the length, and it bounds the trailer read too. A config that fails to load returns the "unreadable" sentinel instead of throwing across the FFI.

  • The sentinel (N = 0, num = 0) now also carries a data type no element type has, so decompress() returns Err(DecompressedDataTypeMismatch) instead of handing the buffer to SZ3 (Copilot's review point). Checked: an oversized payload and a truncated trailer both return Err; an intact stream decompresses.

  • SZ3 3.4.0 removed ALGO_BIOMDXTC: its encoder was adapted from GROMACS's libxdrf.cpp under the LGPL, and SZ3 is now BSD only (szcompressor/SZ3#183). CompressionAlgorithm loses BiologyMolecularDataGromacsXtc and biology_molecular_data_gromacs_xtc(), the test matrix loses its biomdxtc case and the doubled bound it needed. The enum is #[non_exhaustive], but removing a variant is still breaking, hence 0.5.0, as 0.4.0 did for the removed regression options.

  • SZ3 3.4.0's ALGO_BIOMD is a new codec that takes coordinates {frames, atoms, 3} (or {atoms, 3}) only and throws otherwise, so the biomd tests shape the test data as {64, atoms, 3}.
  • 3. Address review (8852f76)


  • The BIOMD tests use {64, 192, 3}, and the wrapper comment reads as suggested.

  • .gitmodules no longer tracks the SZ3 branch sz3-rs.
  • 4. Check the ALGO_BIOMD shape in Rust (cd2733b)


  • compress returns SZ3Error::BiologyMolecularDataShape { dims } for anything but {atoms, 3} or {frames, atoms, 3}, before SZ3 sees the data.
  • 5. Pass SZ3's errors to Rust with their kind and message (fd9025a)


  • Every wrapper function returns an SZ3_ErrorKind and, on an error, sets an out pointer to a copy of the exception's message, which Rust copies and frees through free_error_message. No exception crosses the FFI.

  • The crate returns SZ3Error::InternalError { kind, message }, with kind an InternalErrorKind (InvalidArgument, OutOfRange, Runtime, OutOfMemory, Other).

  • decompress_config returns an error for data shorter than its header, a payload length past the end, and a config that fails to load, and fills the config through an out pointer; the unreadable sentinel from commit 2 is gone.

  • Tests for each of those three, and for the BIOMD shape.
  • Tests

    Locally (Linux, GCC 13, stable Rust): cargo test --all-features 4684 passed, without features 2344 passed, doctests pass, cargo fmt --check clean.

    Diff: 398 lines (+298 / -100) across 4 files Reviewer: juntyr Review duration: 36367m
    All Vouch review confidence checks passed
    Residual risk 0.38 = Change Risk (0.66) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.66 · 398 lines diff across 4 files
    0.66
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.358
    Shallow Review Depth shallow_review_depth
    0.344
    Sensitive Paths sensitive_paths
    0.066
    Real PR Conversation Timeline
    1 comments
    "Review active on #16"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 43.0% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 66.4% (HIGH) · Higher = larger blast radius
    66.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 37.9% · Moderate risk
    37.9%