Commit b371ceb
committed
[1.10>master] [MERGE chakra-core#5451 @paolosevMSFT] Ensure that GeneratorReturnExceptions are not handled by InterpreterStackFrame::DebugProcess
Merge pull request chakra-core#5451 from paolosevMSFT:user/paolosev/bug17418795
When running a generator function with the -debuglaunch flag the engine crashes with simple code like:
```
function* test() {
try {
yield 42;
} catch (e) {
}
}
var t = test();
t.next();
var v = t.return();
```
The reason is that a special exception is thrown by JavascriptOperators::OP_ResumeYield() to carry the return value from a generator. When the generator has a try/catch, like in this case, this exception is caught and rethrown by InterpreterStackFrame::OP_TryCatch(), and after that it is caught and handled by JavascriptGenerator::CallGenerator().
But when we run with -debuglaunch the exception gets caught by InterpreterStackFrame::DebugProcess(), which does not rethrow it. Therefore the generator code does not have a chance to complete correctly and the process crashes because an invalid var is returned in place of a generator yielded object.
As fix this PR adds a check for IsGeneratorReturnException() in InterpreterStackFrame::DebugProcess() to avoid skipping this exception.4 files changed
Lines changed: 48 additions & 40 deletions
File tree
- lib/Runtime/Language
- test
- DebuggerCommon
- es6
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2363 | 2363 | | |
2364 | 2364 | | |
2365 | 2365 | | |
2366 | | - | |
2367 | | - | |
| 2366 | + | |
| 2367 | + | |
| 2368 | + | |
2368 | 2369 | | |
2369 | 2370 | | |
2370 | 2371 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | 127 | | |
131 | 128 | | |
132 | 129 | | |
133 | 130 | | |
134 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
135 | 151 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
524 | 524 | | |
525 | 525 | | |
526 | 526 | | |
527 | | - | |
| 527 | + | |
528 | 528 | | |
529 | 529 | | |
530 | 530 | | |
| |||
540 | 540 | | |
541 | 541 | | |
542 | 542 | | |
543 | | - | |
| 543 | + | |
544 | 544 | | |
545 | 545 | | |
546 | 546 | | |
| |||
550 | 550 | | |
551 | 551 | | |
552 | 552 | | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | | - | |
565 | | - | |
| 553 | + | |
566 | 554 | | |
567 | | - | |
| 555 | + | |
568 | 556 | | |
569 | 557 | | |
570 | 558 | | |
571 | 559 | | |
572 | 560 | | |
573 | 561 | | |
574 | 562 | | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | | - | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
580 | 572 | | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
585 | 577 | | |
586 | 578 | | |
587 | | - | |
| 579 | + | |
588 | 580 | | |
589 | | - | |
| 581 | + | |
590 | 582 | | |
591 | 583 | | |
592 | 584 | | |
593 | 585 | | |
594 | 586 | | |
595 | 587 | | |
596 | 588 | | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
| 589 | + | |
604 | 590 | | |
605 | | - | |
| 591 | + | |
606 | 592 | | |
607 | 593 | | |
608 | 594 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
949 | 949 | | |
950 | 950 | | |
951 | 951 | | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
952 | 957 | | |
953 | 958 | | |
954 | 959 | | |
| |||
0 commit comments