[PATCH] D48148: [scudo] Make Secondary linker-initialized compliant

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 13 13:05:38 PDT 2018


cryptoad created this revision.
cryptoad added a reviewer: alekseyshl.
Herald added subscribers: Sanitizers, delcypher.

As a follow up to https://reviews.llvm.org/D48142 for Scudo, switch the `SpinMutex` to its static
counterpart, and ensure zero-initialization by memset'ing the whole class.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D48148

Files:
  lib/scudo/scudo_allocator_secondary.h


Index: lib/scudo/scudo_allocator_secondary.h
===================================================================
--- lib/scudo/scudo_allocator_secondary.h
+++ lib/scudo/scudo_allocator_secondary.h
@@ -69,11 +69,7 @@
 class ScudoLargeMmapAllocator {
  public:
   void Init() {
-    NumberOfAllocs = 0;
-    NumberOfFrees = 0;
-    AllocatedBytes = 0;
-    FreedBytes = 0;
-    LargestSize = 0;
+    internal_memset(this, 0, sizeof(*this));
   }
 
   void *Allocate(AllocatorStats *Stats, uptr Size, uptr Alignment) {
@@ -186,7 +182,7 @@
   static constexpr uptr HeadersSize =
       LargeChunk::getHeaderSize() + Chunk::getHeaderSize();
 
-  SpinMutex StatsMutex;
+  StaticSpinMutex StatsMutex;
   u32 NumberOfAllocs;
   u32 NumberOfFrees;
   uptr AllocatedBytes;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48148.151235.patch
Type: text/x-patch
Size: 763 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180613/1feda816/attachment.bin>


More information about the llvm-commits mailing list