Repository navigation
Commit bc58034
committed
Leave a method ready to run again after a kernel throws
Method::execute keeps its progress in the method, and resets it when an
instruction returns an error. When a kernel or a backend throws a C++
exception instead, the exception leaves execute() halfway with the progress
still set. Every later execute() then fails with InvalidState ("Method
execution is in progress") until the method is loaded again. So a caller
that catches the exception, such as a Python binding, cannot run the method
again.
The same exception also skips the reset of the temporary allocator that
follows every instruction. Temporary memory the kernel took before it threw
stays allocated. With the default allocator, which uses malloc, that memory
leaks if the caller destroys the method instead of running it again.
execute() now resets its progress however it ends, and each instruction
resets the temporary allocator however it ends, also when an exception
passes through. Runs that return normally behave as before. Builds without
exception support are not affected.1 parent ba0d826 commit bc58034
2 files changed
Lines changed: 70 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1716 | 1716 | | |
1717 | 1717 | | |
1718 | 1718 | | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
1719 | 1729 | | |
1720 | 1730 | | |
1721 | 1731 | | |
| |||
1853 | 1863 | | |
1854 | 1864 | | |
1855 | 1865 | | |
1856 | | - | |
1857 | | - | |
1858 | | - | |
1859 | | - | |
1860 | 1866 | | |
1861 | 1867 | | |
1862 | 1868 | | |
| |||
1972 | 1978 | | |
1973 | 1979 | | |
1974 | 1980 | | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
1975 | 1988 | | |
1976 | 1989 | | |
1977 | 1990 | | |
| |||
1999 | 2012 | | |
2000 | 2013 | | |
2001 | 2014 | | |
2002 | | - | |
2003 | 2015 | | |
2004 | 2016 | | |
2005 | 2017 | | |
| |||
2013 | 2025 | | |
2014 | 2026 | | |
2015 | 2027 | | |
2016 | | - | |
2017 | 2028 | | |
2018 | 2029 | | |
2019 | 2030 | | |
2020 | 2031 | | |
2021 | 2032 | | |
2022 | 2033 | | |
2023 | 2034 | | |
2024 | | - | |
2025 | | - | |
2026 | | - | |
| 2035 | + | |
2027 | 2036 | | |
2028 | 2037 | | |
2029 | 2038 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
74 | 78 | | |
75 | 79 | | |
| 80 | + | |
76 | 81 | | |
77 | 82 | | |
78 | 83 | | |
| |||
160 | 165 | | |
161 | 166 | | |
162 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
163 | 174 | | |
164 | 175 | | |
165 | 176 | | |
| |||
298 | 309 | | |
299 | 310 | | |
300 | 311 | | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
301 | 341 | | |
302 | 342 | | |
303 | 343 | | |
| |||
343 | 383 | | |
344 | 384 | | |
345 | 385 | | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
346 | 398 | | |
347 | 399 | | |
348 | 400 | | |
| |||
0 commit comments