Skip to content

Commit 930ecfd

Browse files
Add isTensor guard in FreeCall to prevent abort on corrupted PTE
Differential Revision: D99727453 Pull Request resolved: #18803
1 parent 9a10876 commit 930ecfd

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

runtime/executor/method.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,8 +1521,17 @@ Error Method::execute_instruction() {
15211521
// We know that instr_args_as_FreeCall is non-null because it was checked
15221522
// at init time.
15231523
auto free_call = instruction->instr_args_as_FreeCall();
1524-
auto t = mutable_value(free_call->value_index()).toTensor();
1525-
internal::reset_data_ptr(t);
1524+
auto& val = mutable_value(free_call->value_index());
1525+
if (val.isTensor()) {
1526+
auto& t = val.toTensor();
1527+
internal::reset_data_ptr(t);
1528+
} else {
1529+
ET_LOG(
1530+
Error,
1531+
"FreeCall target at index %u is not a Tensor",
1532+
static_cast<unsigned int>(free_call->value_index()));
1533+
err = Error::InvalidProgram;
1534+
}
15261535
} break;
15271536
default:
15281537
ET_LOG(

0 commit comments

Comments
 (0)