Skip to content

SWF(bug): cap GGUF metadata array nesting - #93

Merged
maplepaladin73 merged 1 commit into
mainfrom
devin/1795407349-gguf-metadata-depth
Nov 23, 2026
Merged

maplepaladin73 merged 1 commit into
mainfrom
devin/1795407349-gguf-metadata-depth

Conversation

@maplepaladin73

@maplepaladin73 maplepaladin73 commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Malformed GGUF metadata arrays no longer recurse without bound: read_value now tracks array nesting and rejects metadata deeper than 128 levels with a normal parse error. The cap is far above the shallow nested arrays used by valid GGUF metadata, so existing nested-array parsing is unchanged.

Root cause: MetaValue::Array decoding recursively called read_value for element type 9. A crafted file could nest arrays once per ~12 bytes, so GgufFile::parse overflowed the stack before tensor validation.

Test plan

Try it (CPU):

ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 RUST_MIN_STACK=2097152 cargo test -p spark-runtime --lib weights::gguf::container::tests::rejects_excessively_nested_metadata_arrays -- --exact --nocapture
  • Before: the same regression test on main (5938b448) aborted with thread 'weights::gguf::container::tests::rejects_excessively_nested_metadata_arrays' has overflowed its stack / SIGABRT.
  • After: targeted test → 1 passed; container tests → 8 passed; full ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo test -p spark-runtime --lib → 585 passed; 0 failed; 11 ignored.
  • cargo fmt --all -- --check
  • ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo clippy --workspace --tests -- -Dwarnings
  • bash scripts/check-license-headers.sh (4283 files checked, 0 invalid)
  • typos
  • Added regression coverage for a 200,000-level nested metadata array.
  • Untested: real model / GPU load (CPU-only parser change).

Notes for reviewers

The existing nested_array_of_arrays test still passes, covering valid nested metadata. The 128-level cap is generous for real GGUF metadata while keeping recursion bounded well below stack limits.

CLA


Software Factory opened this PR for Robert
Implemented in session Cap GGUF metadata array nesting depth
Review with Devin · Open in Devin Desktop


Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@maplepaladin73
maplepaladin73 merged commit 3b7bc4a into main Nov 23, 2026
1 check passed
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