Skip to content

Commit

Permalink
initialize runtime just before initializing the thread (dotnet#1285)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonerdo committed Nov 11, 2017
1 parent bd42322 commit 6738e30
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Native/Runtime/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1115,8 +1115,11 @@ FORCEINLINE bool Thread::InlineTryFastReversePInvoke(ReversePInvokeFrame * pFram
return true;
}

extern "C" int InitializeRuntime();

void Thread::ReversePInvokeAttachOrTrapThread(ReversePInvokeFrame * pFrame)
{
InitializeRuntime();
if (!IsStateSet(TSF_Attached))
ThreadStore::AttachCurrentThread();

Expand Down Expand Up @@ -1284,14 +1287,9 @@ COOP_PINVOKE_HELPER(UInt8*, RhCurrentNativeThreadId, ())
}
#endif // CORERT

extern "C" int InitializeRuntime();

// Standard calling convention variant and actual implementation for RhpReversePInvokeAttachOrTrapThread
EXTERN_C NOINLINE void FASTCALL RhpReversePInvokeAttachOrTrapThread2(ReversePInvokeFrame * pFrame)
{
// Entrypoint for reverse PInvoke
// ensure runtime is initialized
InitializeRuntime();
ASSERT(pFrame->m_savedThread == ThreadStore::RawGetCurrentThread());
pFrame->m_savedThread->ReversePInvokeAttachOrTrapThread(pFrame);
}
Expand Down

0 comments on commit 6738e30

Please sign in to comment.