Skip to content

Commit 3c7ff01

Browse files
author
Meghana Gupta
committed
[MERGE #6083 @meg-gupta] OS#19405757: Don't reset hasBailedOut bit when we bailout from a non exception finally region
Merge pull request #6083 from meg-gupta:hasBailoutBug We use hasBailedOut bit to indicate wheter we have to catch the exception or pass the exception up the call stack. For this, we maintain a stack of hasBailedOut bit ptrs based on exception handling depth via ctors/dtors when we enter/leave an exception handling region. But, we execute non-exception finally after the dtor pops off the current exception handling region's hasBailedOut bit. Therefore, setting it on bailout would be incorrect, because the top of the stack of hasBailedOut bits is not of the current try-finally, but of its parent.
2 parents 5e53397 + fdad6ff commit 3c7ff01

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

lib/Backend/BailOut.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ BailOutRecord::BailOutInlinedCommon(Js::JavascriptCallStackLayout * layout, Bail
11781178
bool * hasBailedOutBitPtr = layout->functionObject->GetScriptContext()->GetThreadContext()->GetHasBailedOutBitPtr();
11791179
Assert(!bailOutRecord->ehBailoutData || hasBailedOutBitPtr ||
11801180
bailOutRecord->ehBailoutData->ht == Js::HandlerType::HT_Finally /* When we bailout from inlinee in non exception finally, we maynot see hasBailedOutBitPtr*/);
1181-
if (hasBailedOutBitPtr && bailOutRecord->ehBailoutData)
1181+
if (hasBailedOutBitPtr && bailOutRecord->ehBailoutData && bailOutRecord->ehBailoutData->ht != Js::HandlerType::HT_Finally)
11821182
{
11831183
*hasBailedOutBitPtr = true;
11841184
}

test/EH/hasBailedOutBug3.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
6+
WScript.Echo = function (n) {
7+
formatOutput(n.toString());
8+
};
9+
function formatOutput(n) {
10+
return n.replace(/[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/g, function () {
11+
});
12+
}
13+
function test0() {
14+
var GiantPrintArray = [];
15+
var protoObj0 = {};
16+
try {
17+
function func36() {
18+
try {
19+
}
20+
finally {
21+
WScript.Echo('' + b);
22+
GiantPrintArray.push(protoObj0);
23+
}
24+
}
25+
func36();
26+
__loopSecondaryVar3_0;
27+
} catch (ex) {
28+
b = ex;
29+
}
30+
}
31+
test0();
32+
test0();
33+
test0();
34+
print("Passed\n");
35+

test/EH/rlexe.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@
189189
<tags>exclude_dynapogo</tags>
190190
</default>
191191
</test>
192+
<test>
193+
<default>
194+
<files>hasBailedOutBug3.js</files>
195+
</default>
196+
</test>
192197
<test>
193198
<default>
194199
<files>StackOverflow.js</files>

0 commit comments

Comments
 (0)