Commit 26b8b8b
authored
Avoid segfault in ExecutionContext.__exit__ when kernel throws (#4066)
When a kernel raises inside a with ExecutionContext block (cudaq.observe
called with a list argument that is too short), the __exit__ exception
was still calling platform.finalizeExecutionContext(). On the custatevec
GPU backend this triggers an API call against an uninitialized simulator
state, causing a segfault.
Update: Have put back the `finalizeExecutionContext` in __exit__ and
handling the 0 allocated qubits inside simulator.
Found second issue. When there are 0 qubit allocated, calling
setToZeroState (in endExecution) on an unitialized GPU state causes
segfault as was evident from the failing jobs in the first run of this
PR.
Adding a fix to handle a case for the observe path via
handleObservation.
Fixes #4062
---------
Signed-off-by: Sachin Pisal <spisal@nvidia.com>1 parent 91c5729 commit 26b8b8b
File tree
2 files changed
+46
-0
lines changed- python/tests/builder
- runtime/nvqir
2 files changed
+46
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
576 | 576 | | |
577 | 577 | | |
578 | 578 | | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
579 | 611 | | |
580 | 612 | | |
581 | 613 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
966 | 966 | | |
967 | 967 | | |
968 | 968 | | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
969 | 972 | | |
970 | 973 | | |
971 | 974 | | |
| |||
1045 | 1048 | | |
1046 | 1049 | | |
1047 | 1050 | | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
1048 | 1056 | | |
1049 | 1057 | | |
1050 | 1058 | | |
| |||
1286 | 1294 | | |
1287 | 1295 | | |
1288 | 1296 | | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
1289 | 1303 | | |
1290 | 1304 | | |
1291 | 1305 | | |
| |||
0 commit comments