KUDU-680, we started to see the occasional heap-use-after-free when destructing the new thread-local cache. The issue seems to be:
- the thread uses LongAdder somewhere, which allocates a threadlocal 'struct HashCode'
- the thread also uses the threadlocal block cache
On thread destruction, we are running the LongAdder HashCode destructor first, and then running the threadlocal cache destructor. The threadlocal cache runs 'Release()' on the cached blocks, which tries to update the cache's LongAdder-based metrics. This then accesses the hashcode threadlocal which has already been destructed.