Skip to content

Commit c1d9a77

Browse files
author
Thomas Moore (CHAKRA)
committed
Fix bugs found from testing
- Improper buffer used for Utf8SourceInfo - Unnecessary assert in RunBgParseSync - Fix additional memory leak before shutdown
1 parent ae1ce2f commit c1d9a77

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

bin/ChakraCore/ChakraCoreDllFunc.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ EXTERN_C BOOL WINAPI DllMain(HINSTANCE hmod, DWORD dwReason, PVOID pvReserved)
154154
else
155155
{
156156
ThreadBoundThreadContextManager::DestroyAllContexts();
157+
DetachProcess();
157158
ThreadContext::ReportAndCheckLeaksOnProcessDetach();
158159
}
159160
#endif

bin/ch/HostConfigFlagsList.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ FLAG(bool, Test262, "load Test262 harness", false)
2020
FLAG(bool, Module, "load the script as a module", false)
2121
FLAG(bool, TrackRejectedPromises, "Enable tracking of unhandled promise rejections", false)
2222
FLAG(BSTR, CustomConfigFile, "Custom config file to be used to pass in additional flags to Chakra", NULL)
23-
FLAG(bool, ExecuteWithBgParse, "[No-op] Load script with bgparse (note: requires bgparse to be on as well)", false)
23+
FLAG(bool, ExecuteWithBgParse, "Load script with bgparse (note: requires bgparse and parserstatecache be on as well)", false)
2424
#undef FLAG
2525
#endif

bin/ch/ch.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ UINT32 snapHistoryLength = MAXUINT32;
3939
LPCWSTR connectionUuidString = NULL;
4040
UINT32 startEventCount = 1;
4141

42+
HRESULT RunBgParseSync(LPCSTR fileContents, UINT lengthBytes, const char* fileName);
43+
4244
extern "C"
4345
HRESULT __stdcall OnChakraCoreLoadedEntry(TestHooks& testHooks)
4446
{
@@ -462,8 +464,9 @@ HRESULT RunScript(const char* fileName, LPCSTR fileContents, size_t fileLength,
462464
IfJsErrorFailLog(ChakraRTInterface::JsCreateExternalArrayBuffer((void*)fileContents,
463465
(unsigned int)fileLength,
464466
fileContentsFinalizeCallback, (void*)fileContents, &scriptSource));
467+
465468
#if ENABLE_TTD
466-
if(doTTRecord)
469+
if (doTTRecord)
467470
{
468471
JsPropertyIdRef ttProperty = nullptr;
469472
JsValueRef ttString = nullptr;
@@ -769,8 +772,7 @@ HRESULT RunBgParseSync(LPCSTR fileContents, UINT lengthBytes, const char* fileNa
769772
for (int i = 0; i < fileNameLength; i++)
770773
{
771774
fileNameWide[i] = fileName[i];
772-
}
773-
775+
}
774776

775777
JsScriptContents scriptContents = { 0 };
776778
scriptContents.container = (LPVOID)fileContents;
@@ -793,9 +795,8 @@ HRESULT RunBgParseSync(LPCSTR fileContents, UINT lengthBytes, const char* fileNa
793795
nullptr,//_In_ JsValueRef parserState,
794796
&bgResult
795797
);
796-
Assert(e == JsErrorCode::JsNoError);
797798

798-
return S_OK;
799+
return e;
799800
}
800801

801802
HRESULT ExecuteTest(const char* fileName)

lib/Parser/BGParseManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ HRESULT BGParseWorkItem::DeserializeParseResults(
590590
{
591591
scriptContextUI->MakeUtf8SourceInfo(
592592
this->script,
593-
this->parseSourceLength,
593+
this->cb,
594594
pSrcInfo,
595595
&utf8SourceInfo,
596596
LoadScriptFlag_Utf8Source,

0 commit comments

Comments
 (0)