[PATCH] D71719: [scudo][standalone] Implement TSD registry disabling

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 19 10:42:47 PST 2019


cryptoad created this revision.
cryptoad added reviewers: cferris, pcc, hctim, morehouse, eugenis.
Herald added subscribers: Sanitizers, jfb.
Herald added projects: Sanitizers, LLVM.

In order to implement `malloc_{enable|disable}` we were just disabling
(or really locking) the Primary and the Secondary. That meant that
allocations could still be serviced from the TSD as long as the cache
wouldn't have to be filled from the Primary.

This wasn't working out for Android tests, so this change implements
registry disabling (eg: locking) so that `getTSDAndLock` doesn't
return a TSD if the allocator is disabled. This also means that the
Primary doesn't have to be disabled in this situation.

For the Shared Registry, we loop through all the TSDs and lock them.
For the Exclusive Registry, we add a `Disabled` boolean to the Registry
that forces `getTSDAndLock` to use the Fallback TSD instead of the
thread local one. Disabling the Registry is then done by locking the
Fallback TSD and setting the boolean in question (I don't think this
needed an atomic variable but I might be wrong).

I clang-formatted the whole thing as usual hence the couple of extra
whiteline changes in this CL.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71719

Files:
  compiler-rt/lib/scudo/standalone/combined.h
  compiler-rt/lib/scudo/standalone/flags.cpp
  compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
  compiler-rt/lib/scudo/standalone/tsd_exclusive.h
  compiler-rt/lib/scudo/standalone/tsd_shared.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71719.234750.patch
Type: text/x-patch
Size: 4286 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191219/b5bf082e/attachment-0001.bin>


More information about the llvm-commits mailing list