Commit c4983ce
Add instruction execution limit to prevent infinite loops (#18679)
JumpFalseCall instructions can set destination_instruction to
themselves, creating an infinite loop that hangs the runtime. This adds
a configurable instruction counter (default 10M, overridable via
-DET_MAX_INSTRUCTIONS) to Method::execute() that returns
Error::InvalidState if exceeded.
This PR was authored with the assistance of Claude.
### Test plan
Existing tests
```bash
cmake -B build -DEXECUTORCH_BUILD_TESTS=ON
cmake --build build --target method_test
ctest --test-dir build -R method_test --output-on-failure
```
Co-authored-by: Github Executorch <github_executorch@arm.com>1 parent 78a6689 commit c4983ce
1 file changed
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
40 | 54 | | |
41 | 55 | | |
42 | 56 | | |
| |||
1664 | 1678 | | |
1665 | 1679 | | |
1666 | 1680 | | |
| 1681 | + | |
1667 | 1682 | | |
1668 | 1683 | | |
1669 | 1684 | | |
| |||
1677 | 1692 | | |
1678 | 1693 | | |
1679 | 1694 | | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
1680 | 1710 | | |
1681 | 1711 | | |
1682 | 1712 | | |
| |||
0 commit comments