Skip to content

Commit bc2fb21

Browse files
committed
[1.4>master] [MERGE chakra-core#2249 @tcare] AutoRestoreFunctionInfo does not handle throw during initialization
Merge pull request chakra-core#2249 from tcare:redefer Fixes OS 10106951. Paul's recent change in chakra-core#2149 misses a case where we throw during creation of the new function body. We then assert because we did not restore the original function body. Fixed by detecting the case where the function has not been parsed and we did not finish creating the new function body, using the ParsableFunctionInfo to restore the original state.
2 parents 8ddb129 + f4e226b commit bc2fb21

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/Runtime/Base/FunctionBody.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,24 +2138,24 @@ namespace Js
21382138
public:
21392139
AutoRestoreFunctionInfo(ParseableFunctionInfo *pfi) : pfi(pfi), funcBody(nullptr) {}
21402140
~AutoRestoreFunctionInfo() {
2141-
if (this->funcBody && this->funcBody->GetFunctionInfo()->GetFunctionProxy() == this->funcBody)
2141+
if (this->pfi != nullptr && this->pfi->GetFunctionInfo()->GetFunctionProxy() != this->pfi)
21422142
{
2143-
FunctionInfo *functionInfo = funcBody->GetFunctionInfo();
2143+
FunctionInfo *functionInfo = this->pfi->functionInfo;
21442144
functionInfo->SetAttributes(
21452145
(FunctionInfo::Attributes)(functionInfo->GetAttributes() | FunctionInfo::Attributes::DeferredParse));
21462146
functionInfo->SetFunctionProxy(this->pfi);
21472147
functionInfo->SetOriginalEntryPoint(DefaultEntryThunk);
21482148
}
2149-
Assert(this->pfi == nullptr ||
2150-
(this->pfi->GetFunctionInfo()->GetFunctionProxy() == this->pfi && !this->pfi->IsFunctionBody()));
2149+
2150+
Assert(this->pfi == nullptr || (this->pfi->GetFunctionInfo()->GetFunctionProxy() == this->pfi && !this->pfi->IsFunctionBody()));
21512151
}
21522152
void Clear() { pfi = nullptr; funcBody = nullptr; }
2153-
2153+
21542154
ParseableFunctionInfo * pfi;
21552155
FunctionBody * funcBody;
21562156
} autoRestoreFunctionInfo(this);
21572157

2158-
// If m_hasBeenParsed = true, one of the following things happened things happened:
2158+
// If m_hasBeenParsed = true, one of the following things happened:
21592159
// - We had multiple function objects which were all defer-parsed, but with the same function body and one of them
21602160
// got the body to be parsed before another was called
21612161
// - We are in debug mode and had our thunks switched to DeferParseThunk

0 commit comments

Comments
 (0)