[PATCH] D59269: ELF: Use bump pointer allocator for uncompressed section buffers. NFCI.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 12 13:06:26 PDT 2019


pcc added a comment.

In D59269#1426677 <https://reviews.llvm.org/D59269#1426677>, @ruiu wrote:

> I thought that we could protect `BumpPtrAllocator::Allocate` with a mutex, but since StringSaver directly calls that function, there's no way to acquire a lock before calling that function. Maybe we should protect `StringSaver::save`?


We could, I suppose? But then that code would be effectively dead since we don't save any strings on the main thread right now. I'm more inclined to let TSan find any mistakes involving `BumpPtrAllocator` here.

> Or, we could also make BAlloc and StringSaver thread-local variables. That might be a better approach.

I'm not sure if that will work. Imagine that we spin up a thread that decompresses a section and then terminates. When the thread terminates, the allocator is destroyed, so we are left with a dangling pointer in the section object.

We could work around that by having the thread local variables be pointers to objects allocated on the heap, and arrange for them to be destroyed later in `lld::freeArena`. But now we're back to the original problem of thread-safely adding a "thing to deallocate later" to a list.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59269/new/

https://reviews.llvm.org/D59269





More information about the llvm-commits mailing list