Skip to content

gguf: accept zero-sized tensor dimensions - #26701

Closed
jeevan6996 wants to merge 1 commit into
ggml-org:masterfrom
jeevan6996:fix/gguf-zero-dimension
Closed

gguf: accept zero-sized tensor dimensions#26701
jeevan6996 wants to merge 1 commit into
ggml-org:masterfrom
jeevan6996:fix/gguf-zero-dimension

Conversation

@jeevan6996

@jeevan6996 jeevan6996 commented Aug 7, 2026

Copy link
Copy Markdown

Overview

Fixes #26366 gguf loading for valid tensors with zero-sized dimensions.

Existing overflow validation divides by tensor dimensions, causing SIGFPE on x86-64 when a dimension is zero.

Solution: Detect zero dimensions and skip those divisions while retaining overflow validation for nonzero dimensions.

Additional information

Testing: Added a regression test using a valid GGUF tensor shaped [1, 0].

Validation: CPU-only build completed; all 89/89 test-gguf tests passed.

Requirements

@github-actions github-actions Bot added testing Everything test related ggml changes relating to the ggml tensor library for machine learning labels Aug 7, 2026
@Green-Sky
Green-Sky self-requested a review August 7, 2026 08:04

@Green-Sky Green-Sky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me.

Comment thread tests/test-gguf.cpp
return ok;
}

static FILE * get_zero_dim_tensor_file() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Simplify this by adding HANDCRAFTED_TENSORS_ZERO_DIM instead.

@CISC

CISC commented Aug 12, 2026

Copy link
Copy Markdown
Member

Superseded by #25596

@CISC CISC closed this Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gguf: SIGFPE on x86-64 from a zero tensor dimension (valid GGUF, accepted by gguf-py)

3 participants