Skip to content

runtime: null-check sizes and dim_order in validateTensorLayout#19878

Open
vacu9708 wants to merge 1 commit into
pytorch:mainfrom
vacu9708:fix/validate-tensor-layout-null-checks
Open

runtime: null-check sizes and dim_order in validateTensorLayout#19878
vacu9708 wants to merge 1 commit into
pytorch:mainfrom
vacu9708:fix/validate-tensor-layout-null-checks

Conversation

@vacu9708
Copy link
Copy Markdown
Contributor

Summary

validateTensorLayout dereferences s_tensor->sizes() and s_tensor->dim_order() without null-checking them first. Both fields are nullable in the schema, and the function is called from Method::parse_external_constants before parseTensor (which does null-check both) runs. Under the default Verification::Minimal, a corrupted .pte/.ptd with either field null causes a SIGSEGV instead of a clean error return.

This PR adds the two missing null guards. Same pattern as #19267 and #17131, which hardened the same function.

Error code: used InvalidExternalData to match the other checks inside validateTensorLayout.

Test result

./test/run_oss_cpp_tests.sh
lintrunner runtime/executor/tensor_parser_exec_aten.cpp \
           runtime/executor/test/tensor_parser_test.cpp

Result: 0 tests failed out of 82. Lint clean.

`validateTensorLayout` is called from `Method::parse_external_constants`
before `parseTensor` runs its own null checks. Under the default
`Verification::Minimal`, a null `sizes` or `dim_order` field in a
corrupted PTE causes a SIGSEGV instead of a clean error return.

Fixes the gap and adds two regression tests.

Signed-off-by: Youngsik Yang <vacu9708@gmail.com>
@vacu9708 vacu9708 requested a review from JacobSzwejbka as a code owner May 29, 2026 16:44
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 29, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19878

Note: Links to docs will display an error until the docs builds have been completed.

❌ You can merge normally! (2 Unrelated Failures), 1 Unclassified Failure

As of commit fa988fd with merge base acce7cd (image):

UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 29, 2026
@github-actions
Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants