diff options
author | Jan Vorlicek <janvorli@microsoft.com> | 2018-11-16 19:08:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-16 19:08:29 +0100 |
commit | 488d2a70ba59c58b26aa3f4f988a42f6b8927146 (patch) | |
tree | edfa9a20628c2c8d503a17534434c7b0ac87d97a /src/vm/methodtable.inl | |
parent | 7f22a149708a9ad6a90b9a92b78c12a7f4ae9d41 (diff) | |
download | coreclr-488d2a70ba59c58b26aa3f4f988a42f6b8927146.tar.gz coreclr-488d2a70ba59c58b26aa3f4f988a42f6b8927146.tar.bz2 coreclr-488d2a70ba59c58b26aa3f4f988a42f6b8927146.zip |
Fix unloadability races (#21024)
* Fix LoaderAllocator::AllocateHandle
When another thread wins the race in growing the handle table, the code
was not refreshing the slotsUsed local to the new up to date value. This
was leading to overwriting / reusing a live handle.
This change fixes it.
* Embed ThreadLocalBlock in Thread
Instead of allocating ThreadLocalBlock dynamically, embed it in the
Thread. That solves race issue between thread destruction and
LoaderAllocator destruction. The ThreadLocalBlock could have been
deleted during Thread shutdown while the LoaderAllocator's destruction
would be working with it.
Diffstat (limited to 'src/vm/methodtable.inl')
-rw-r--r-- | src/vm/methodtable.inl | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/vm/methodtable.inl b/src/vm/methodtable.inl index 88ce26cffd..d998f1fe36 100644 --- a/src/vm/methodtable.inl +++ b/src/vm/methodtable.inl @@ -1408,9 +1408,7 @@ inline PTR_BYTE MethodTable::GetNonGCThreadStaticsBasePointer() // Get the current module's ModuleIndex ModuleIndex index = GetModuleForStatics()->GetModuleIndex(); - PTR_ThreadLocalBlock pTLB = ThreadStatics::GetCurrentTLBIfExists(pThread, NULL); - if (pTLB == NULL) - return NULL; + PTR_ThreadLocalBlock pTLB = ThreadStatics::GetCurrentTLB(pThread); PTR_ThreadLocalModule pTLM = pTLB->GetTLMIfExists(index); if (pTLM == NULL) @@ -1436,9 +1434,7 @@ inline PTR_BYTE MethodTable::GetGCThreadStaticsBasePointer() // Get the current module's ModuleIndex ModuleIndex index = GetModuleForStatics()->GetModuleIndex(); - PTR_ThreadLocalBlock pTLB = ThreadStatics::GetCurrentTLBIfExists(pThread, NULL); - if (pTLB == NULL) - return NULL; + PTR_ThreadLocalBlock pTLB = ThreadStatics::GetCurrentTLB(pThread); PTR_ThreadLocalModule pTLM = pTLB->GetTLMIfExists(index); if (pTLM == NULL) @@ -1450,16 +1446,14 @@ inline PTR_BYTE MethodTable::GetGCThreadStaticsBasePointer() #endif //!DACCESS_COMPILE //========================================================================================== -inline PTR_BYTE MethodTable::GetNonGCThreadStaticsBasePointer(PTR_Thread pThread, PTR_AppDomain pDomain) +inline PTR_BYTE MethodTable::GetNonGCThreadStaticsBasePointer(PTR_Thread pThread) { LIMITED_METHOD_DAC_CONTRACT; // Get the current module's ModuleIndex ModuleIndex index = GetModuleForStatics()->GetModuleIndex(); - PTR_ThreadLocalBlock pTLB = ThreadStatics::GetCurrentTLBIfExists(pThread, pDomain); - if (pTLB == NULL) - return NULL; + PTR_ThreadLocalBlock pTLB = ThreadStatics::GetCurrentTLB(pThread); PTR_ThreadLocalModule pTLM = pTLB->GetTLMIfExists(index); if (pTLM == NULL) @@ -1469,16 +1463,14 @@ inline PTR_BYTE MethodTable::GetNonGCThreadStaticsBasePointer(PTR_Thread pThread } //========================================================================================== -inline PTR_BYTE MethodTable::GetGCThreadStaticsBasePointer(PTR_Thread pThread, PTR_AppDomain pDomain) +inline PTR_BYTE MethodTable::GetGCThreadStaticsBasePointer(PTR_Thread pThread) { LIMITED_METHOD_DAC_CONTRACT; // Get the current module's ModuleIndex ModuleIndex index = GetModuleForStatics()->GetModuleIndex(); - PTR_ThreadLocalBlock pTLB = ThreadStatics::GetCurrentTLBIfExists(pThread, pDomain); - if (pTLB == NULL) - return NULL; + PTR_ThreadLocalBlock pTLB = ThreadStatics::GetCurrentTLB(pThread); PTR_ThreadLocalModule pTLM = pTLB->GetTLMIfExists(index); if (pTLM == NULL) |