[PR #3394] [CLOSED] [Engine] make strata-gguf --check reject invalid files #4613

Closed
opened 2026-11-07 15:37:49 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3394
Author: @j-luwierski
Created: 10/20/2026
Status: ❌ Closed

Base: main ← Head: codex/gguf-check-validation-rebased


📝 Commits (1)

  • a2aee5f [Engine] reject invalid strata-gguf checks

📊 Changes

3 files changed (+113 additions, -3 deletions)

View changed files

📝 CMakeLists.txt (+4 -0)
📝 src/artifact/gguf_reader.cpp (+6 -3)
➕ tests/core/gguf_cli_test.cpp (+103 -0)

📄 Description

Problem and result

On current main (5bda973a), strata-gguf FILE --check prints an architecture failure but returns status 0. Its geometry check can also accept an out-of-file tensor offset when unsigned subtraction wraps, and a tensor whose byte count overflows. After this change, these checks return status 1. Inspection without --check remains unchanged.

Rechecked after the 0.2.0-beta tracker reset: #3043 and #3044. The maintainer noted that closure during the reset does not mean rejection.

Approach

Use the existing overflow-safe tensor_payload_bytes() helper, validate the payload offset before subtracting, and return failure when the architecture guard reports an error. Add a CPU-only CTest that invokes the actual CLI entry point on synthetic GGUFs covering valid and invalid inputs.

Validation

Environment: Linux x86_64, GCC 14.2.0. Tested on current main 5bda973a4331212494d74cf35927ada7f0e063e7 plus candidate a2aee5fb.

Passed:

  • cmake -S . -B build-pr3044 -DSTRATA_BUILD_TESTS=ON -DSTRATA_WERROR=ON -DSTRATA_ENABLE_CUDA=OFF -DSTRATA_ENABLE_HIP=OFF -DSTRATA_ENABLE_SYCL=OFF: configured successfully.
  • cmake --build build-pr3044 --target strata-gguf gguf_cli_test gguf_reader_test gguf_split_test gguf_geometry_test model_family_test -j2: all targets built.
  • ctest --test-dir build-pr3044 --output-on-failure -R '^(gguf_cli_test|gguf_reader_test|gguf_split_test|gguf_geometry_test|model_family_test)$': 5/5 passed.
  • git diff --cached --check: clean.

Failed on unchanged base (expected regression evidence):

  • Compiled and ran the new CLI regression test against 5bda973a. It exited 1 because unsupported and missing architecture, a wrapped out-of-file offset, and an overflowing tensor byte count returned 0 instead of 1. The valid file, inspection-only mode, ordinary out-of-file offset and truncation cases behaved as expected.

Not run:

  • Full repository suite, model inference, Windows/macOS runtime, and CUDA/HIP/SYCL builds. The change is confined to the standalone host CLI and its CPU-only test.

Limits

The check still reports unknown tensor types separately; this change only makes known invalid payload bounds and architecture failures affect the exit status.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/3394 **Author:** [@j-luwierski](https://github.com/j-luwierski) **Created:** 10/20/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `codex/gguf-check-validation-rebased` --- ### 📝 Commits (1) - [`a2aee5f`](https://github.com/Niko1221/Strata/commit/a2aee5fbcd726c8301aebd14ecb0ea082cb57467) [Engine] reject invalid strata-gguf checks ### 📊 Changes **3 files changed** (+113 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+4 -0) 📝 `src/artifact/gguf_reader.cpp` (+6 -3) ➕ `tests/core/gguf_cli_test.cpp` (+103 -0) </details> ### 📄 Description ## Problem and result On current `main` (`5bda973a`), `strata-gguf FILE --check` prints an architecture failure but returns status 0. Its geometry check can also accept an out-of-file tensor offset when unsigned subtraction wraps, and a tensor whose byte count overflows. After this change, these checks return status 1. Inspection without `--check` remains unchanged. ## Related discussion Rechecked after the 0.2.0-beta tracker reset: [#3043](https://github.com/Niko1221/Strata/issues/3043) and [#3044](https://github.com/Niko1221/Strata/pull/3044). The maintainer noted that closure during the reset does not mean rejection. ## Approach Use the existing overflow-safe `tensor_payload_bytes()` helper, validate the payload offset before subtracting, and return failure when the architecture guard reports an error. Add a CPU-only CTest that invokes the actual CLI entry point on synthetic GGUFs covering valid and invalid inputs. ## Validation Environment: Linux x86_64, GCC 14.2.0. Tested on current `main` `5bda973a4331212494d74cf35927ada7f0e063e7` plus candidate `a2aee5fb`. **Passed:** - `cmake -S . -B build-pr3044 -DSTRATA_BUILD_TESTS=ON -DSTRATA_WERROR=ON -DSTRATA_ENABLE_CUDA=OFF -DSTRATA_ENABLE_HIP=OFF -DSTRATA_ENABLE_SYCL=OFF`: configured successfully. - `cmake --build build-pr3044 --target strata-gguf gguf_cli_test gguf_reader_test gguf_split_test gguf_geometry_test model_family_test -j2`: all targets built. - `ctest --test-dir build-pr3044 --output-on-failure -R '^(gguf_cli_test|gguf_reader_test|gguf_split_test|gguf_geometry_test|model_family_test)$'`: 5/5 passed. - `git diff --cached --check`: clean. **Failed on unchanged base (expected regression evidence):** - Compiled and ran the new CLI regression test against `5bda973a`. It exited 1 because unsupported and missing architecture, a wrapped out-of-file offset, and an overflowing tensor byte count returned 0 instead of 1. The valid file, inspection-only mode, ordinary out-of-file offset and truncation cases behaved as expected. **Not run:** - Full repository suite, model inference, Windows/macOS runtime, and CUDA/HIP/SYCL builds. The change is confined to the standalone host CLI and its CPU-only test. ## Limits The check still reports unknown tensor types separately; this change only makes known invalid payload bounds and architecture failures affect the exit status. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:37:49 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4613
No description provided.