Validate non-null data pointer in Tensor accessors#19269
Validate non-null data pointer in Tensor accessors#19269rascani wants to merge 1 commit intopytorch:mainfrom
Conversation
Summary: Add null-data-pointer validation to all six data accessor methods on the `Tensor` class (`const_data_ptr`, `mutable_data_ptr`, and deprecated `data_ptr` — two overloads each). The check fires when `numel() > 0` but the underlying `data_` pointer is null, which indicates an invalid tensor state. This prevents null pointer dereferences in all 225+ kernel implementations that call these accessors. The Lionhead fuzzer (`FuzzKernels` harness, T234178948) has been filing 50-100+ crash tasks because it constructs tensors with non-zero numel but null data pointers. Every kernel that dereferences the result of `const_data_ptr()` crashes. This centralized check catches the invalid state at the accessor level, eliminating the entire class of fuzzer findings. Tensors with `numel() == 0` and a null data pointer remain valid (empty tensors). Differential Revision: D103467785
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19269
Note: Links to docs will display an error until the docs builds have been completed. ❌ 7 New Failures, 2 Unrelated FailuresAs of commit dc47f83 with merge base a3dd0fa ( NEW FAILURES - The following jobs have failed:
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. |
|
@rascani has exported this pull request. If you are a Meta employee, you can view the originating Diff in D103467785. |
This PR needs a
|
Summary:
Add null-data-pointer validation to all six data accessor methods on the
Tensorclass (const_data_ptr,mutable_data_ptr, and deprecateddata_ptr— two overloads each).The check fires when
numel() > 0but the underlyingdata_pointer is null, which indicates an invalid tensor state. This prevents null pointer dereferences in all 225+ kernel implementations that call these accessors.The Lionhead fuzzer (
FuzzKernelsharness, T234178948) has been filing 50-100+ crash tasks because it constructs tensors with non-zero numel but null data pointers. Every kernel that dereferences the result ofconst_data_ptr()crashes. This centralized check catches the invalid state at the accessor level, eliminating the entire class of fuzzer findings.Tensors with
numel() == 0and a null data pointer remain valid (empty tensors).Differential Revision: D103467785