Skip to content

Commit 08df52c

Browse files
author
Atul Katti
committed
[MERGE chakra-core#2426 @atulkatti] OOPJIT: Avoid attempting to initialize script context if JIT server process has terminated.
Merge pull request chakra-core#2426 from atulkatti:Bug10152976.JitClientAssert
2 parents 0ab7db7 + 4ec4ba8 commit 08df52c

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

lib/Runtime/Base/ScriptContext.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4566,10 +4566,12 @@ void ScriptContext::RegisterPrototypeChainEnsuredToHaveOnlyWritableDataPropertie
45664566
#ifndef _CONTROL_FLOW_GUARD
45674567
allowPrereserveAlloc = false;
45684568
#endif
4569-
this->GetThreadContext()->EnsureJITThreadContext(allowPrereserveAlloc);
4570-
4571-
HRESULT hr = JITManager::GetJITManager()->InitializeScriptContext(&contextData, this->GetThreadContext()->GetRemoteThreadContextAddr(), &m_remoteScriptContextAddr);
4572-
JITManager::HandleServerCallResult(hr, RemoteCallType::StateUpdate);
4569+
// The EnsureJITThreadContext() call could fail if the JIT Server process has died. In such cases, we should not try to do anything further in the client process.
4570+
if (this->GetThreadContext()->EnsureJITThreadContext(allowPrereserveAlloc))
4571+
{
4572+
HRESULT hr = JITManager::GetJITManager()->InitializeScriptContext(&contextData, this->GetThreadContext()->GetRemoteThreadContextAddr(), &m_remoteScriptContextAddr);
4573+
JITManager::HandleServerCallResult(hr, RemoteCallType::StateUpdate);
4574+
}
45734575
}
45744576
#endif
45754577

lib/Runtime/Base/ThreadContext.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,19 +1943,19 @@ ThreadContext::SetJITConnectionInfo(HANDLE processHandle, void* serverSecurityDe
19431943
JITManager::GetJITManager()->ConnectRpcServer(processHandle, serverSecurityDescriptor, connectionId);
19441944
}
19451945
}
1946-
void
1946+
bool
19471947
ThreadContext::EnsureJITThreadContext(bool allowPrereserveAlloc)
19481948
{
19491949
#if ENABLE_OOP_NATIVE_CODEGEN
19501950
Assert(JITManager::GetJITManager()->IsOOPJITEnabled());
19511951
if (!JITManager::GetJITManager()->IsConnected())
19521952
{
1953-
return;
1953+
return false;
19541954
}
19551955

19561956
if (m_remoteThreadContextInfo)
19571957
{
1958-
return;
1958+
return true;
19591959
}
19601960

19611961
ThreadContextDataIDL contextData;
@@ -1964,7 +1964,7 @@ ThreadContext::EnsureJITThreadContext(bool allowPrereserveAlloc)
19641964
HANDLE jitTargetHandle = nullptr;
19651965
if (!DuplicateHandle(GetCurrentProcess(), GetCurrentProcess(), serverHandle, &jitTargetHandle, 0, FALSE, DUPLICATE_SAME_ACCESS))
19661966
{
1967-
return;
1967+
return false;
19681968
}
19691969

19701970
contextData.processHandle = (intptr_t)jitTargetHandle;
@@ -1996,6 +1996,7 @@ ThreadContext::EnsureJITThreadContext(bool allowPrereserveAlloc)
19961996
HRESULT hr = JITManager::GetJITManager()->InitializeThreadContext(&contextData, &m_remoteThreadContextInfo, &m_prereservedRegionAddr);
19971997
JITManager::HandleServerCallResult(hr, RemoteCallType::StateUpdate);
19981998

1999+
return m_remoteThreadContextInfo != nullptr;
19992000
#endif
20002001
}
20012002
#endif

lib/Runtime/Base/ThreadContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ class ThreadContext sealed :
503503
}
504504

505505
static void SetJITConnectionInfo(HANDLE processHandle, void* serverSecurityDescriptor, UUID connectionId);
506-
void EnsureJITThreadContext(bool allowPrereserveAlloc);
506+
bool EnsureJITThreadContext(bool allowPrereserveAlloc);
507507

508508
PTHREADCONTEXT_HANDLE GetRemoteThreadContextAddr()
509509
{

0 commit comments

Comments
 (0)