Commit 789fc7f
committed
Hold the reentrancy flag while degrading in the fail-safe path
Addresses Copilot review on PR #662.
The fail-safe catch inside prompt delegated to the wrapped prompt WITHOUT
setting $Global:__ShellInteg_Rendering. The normal path clears that flag in its
finally before the catch runs, so an adopted CHAINING prompt calls back into us
with the flag false and the guard does not fire.
Reproduced with a chaining prompt plus a forced failure in the render path:
'CHAIN|CHAIN|CHAIN| ... (130+ levels) ... PS C:\Users\yeelam> '
That is the exact unbounded mutual-delegation cycle the guard exists to
prevent; only the engine's call-depth limit stopped it. After the fix the same
repro returns 'CHAIN|BASE> ' in 12ms, and the base prompt text is preserved.
Two smaller review points in the same commit:
- The test took script.substr(rearmFunc) without first proving rearmFunc is not
npos, so a missing marker would surface as std::out_of_range instead of a
clear VERIFY failure. Added an explicit VERIFY_ARE_NOT_EQUAL.
- check-spelling: 'scriptblocks' is not a recognized word - reworded to
'script blocks'.
RendersFailSafe now asserts the flag is set before the degraded delegation and
cleared in finally; mutation-tested by removing the assignment, which fails the
test as intended.
104/104 ShellIntegrationTests pass. Behavioural suite still green on Windows
PowerShell 5.1 and PowerShell 7, and the script still survives Constrained
Language Mode on both.1 parent a78f404 commit 789fc7f
2 files changed
Lines changed: 23 additions & 9 deletions
Lines changed: 14 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
515 | 515 | | |
516 | 516 | | |
517 | 517 | | |
518 | | - | |
519 | | - | |
520 | | - | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
521 | 523 | | |
522 | 524 | | |
523 | 525 | | |
| |||
628 | 630 | | |
629 | 631 | | |
630 | 632 | | |
631 | | - | |
| 633 | + | |
| 634 | + | |
632 | 635 | | |
| 636 | + | |
633 | 637 | | |
634 | | - | |
| 638 | + | |
635 | 639 | | |
636 | 640 | | |
637 | | - | |
638 | | - | |
639 | | - | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
640 | 646 | | |
641 | 647 | | |
642 | 648 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
588 | 588 | | |
589 | 589 | | |
590 | 590 | | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
591 | 598 | | |
592 | 599 | | |
| 600 | + | |
593 | 601 | | |
594 | 602 | | |
595 | 603 | | |
| |||
619 | 627 | | |
620 | 628 | | |
621 | 629 | | |
622 | | - | |
| 630 | + | |
623 | 631 | | |
624 | 632 | | |
625 | 633 | | |
| |||
0 commit comments