Fix unloadability races (#21024)
authorJan Vorlicek <janvorli@microsoft.com>
Fri, 16 Nov 2018 18:08:29 +0000 (19:08 +0100)
committerGitHub <noreply@github.com>
Fri, 16 Nov 2018 18:08:29 +0000 (19:08 +0100)
commit488d2a70ba59c58b26aa3f4f988a42f6b8927146
treeedfa9a20628c2c8d503a17534434c7b0ac87d97a
parent7f22a149708a9ad6a90b9a92b78c12a7f4ae9d41
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.
15 files changed:
src/debug/daccess/dacdbiimpl.cpp
src/debug/daccess/inspect.cpp
src/debug/daccess/request.cpp
src/gc/objecthandle.cpp
src/vm/appdomain.cpp
src/vm/appdomain.hpp
src/vm/comsynchronizable.cpp
src/vm/loaderallocator.cpp
src/vm/methodtable.h
src/vm/methodtable.inl
src/vm/proftoeeinterfaceimpl.cpp
src/vm/threads.cpp
src/vm/threads.h
src/vm/threadstatics.cpp
src/vm/threadstatics.h