Repository navigation
[runtime] Fix null operator overload logging and named data key dereferences - #24801
AhmadHassan-BTed wants to merge 2 commits into
Conversation
|
Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
|
|
@pytorchbot label "release notes: runtime" |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
@claude review effort:max |
|
Claude finished @JakeStevens's task in 3m 4s —— View job PR Review: #24801This PR fixes the null Detailed reviewSummaryThe PR adds null guards to the Code Quality
Testing
RecommendationRequest Changes: the likely build break with |
|
Thanks for the review @JakeStevens. Updated the PR to address all feedback:
|
…ences Guard against null pointer dereferences when logging KernelCall errors in Method::execute_instruction and when resolving keys in FlatTensorDataMap. - runtime/executor/method.cpp: Check op and op->overload() before invoking c_str() in the KernelCall failure log. Operators with no overload string now format cleanly as op_name without segfaulting. - extension/flat_tensor/flat_tensor_data_map.cpp: In get_named_data, verify entry and entry->key() are non-null before comparison. In get_key, validate index bounds and check entry and entry->key() are non-null before returning, returning InvalidExternalData on malformed entries instead of faulting. - extension/flat_tensor/test/flat_tensor_data_map_test.cpp: Add test coverage for out-of-bounds key access. Fixes pytorch#23955.
…med data errors - Inline operator overload null check in ET_LOG to prevent unused variable warnings when logging is compiled out. - Return InvalidExternalData for keyless or null named data entries in get_named_data and get_key. - Simplify get_num_keys and remove unreachable null check branch. - Add test coverage for keyless named data entries in flat_tensor_data_map_test. - Add test coverage for kernel failure with null operator overload in program_validation_test.
85b6676 to
cea98b1
Compare
Summary
Fixes #23955.
This PR resolves null pointer dereference crashes encountered during runtime error logging and external tensor loading on malformed or minimal .pte and .ptd inputs:
Method::execute_instruction (runtime/executor/method.cpp):
When logging a KernelCall failed error, the logger formatted op->overload()->c_str() unconditionally. If an operator has no overload string in the .pte flatbuffer (or if op is null), calling c_str() results in a SIGSEGV instead of emitting the error diagnostic.
We guard op, op->name(), and check has_overload = op != nullptr && op->overload() != nullptr && op->overload()->size() > 0, formatting as op_name.overload when present and op_name when absent, matching populate_operator_name().
FlatTensorDataMap (extension/flat_tensor/flat_tensor_data_map.cpp):
cc @larryliu0820 @JacobSzwejbka @lucylq @nil-is-all
Test plan