[scudo][standalone] Work with -Werror=class-memaccess
authorKostya Kortchinsky <kostyak@google.com>
Fri, 10 Apr 2020 20:41:12 +0000 (13:41 -0700)
committerKostya Kortchinsky <kostyak@google.com>
Sat, 11 Apr 2020 14:29:12 +0000 (07:29 -0700)
Summary:
Fuchsia's gcc uses this, which in turn prevents us to compile successfully
due to a few `memset`'ing some non-trivial classes in some `init`.

Change those `memset` to members initialization.

Reviewers: pcc, hctim

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D77902

compiler-rt/lib/scudo/standalone/mutex.h
compiler-rt/lib/scudo/standalone/quarantine.h
compiler-rt/lib/scudo/standalone/stats.h

index b26b2df..d6e6a5b 100644 (file)
@@ -22,7 +22,7 @@ namespace scudo {
 
 class HybridMutex {
 public:
-  void init() { memset(this, 0, sizeof(*this)); }
+  void init() { M = {}; }
   bool tryLock();
   NOINLINE void lock() {
     if (LIKELY(tryLock()))
index 406a0e2..27aa4bf 100644 (file)
@@ -187,7 +187,12 @@ public:
     Cache.initLinkerInitialized();
   }
   void init(uptr Size, uptr CacheSize) {
-    memset(this, 0, sizeof(*this));
+    CacheMutex.init();
+    Cache.init();
+    RecycleMutex.init();
+    MinSize = {};
+    MaxSize = {};
+    MaxCacheSize = {};
     initLinkerInitialized(Size, CacheSize);
   }
 
index 38481e9..d76b904 100644 (file)
@@ -58,7 +58,9 @@ class GlobalStats : public LocalStats {
 public:
   void initLinkerInitialized() {}
   void init() {
-    memset(this, 0, sizeof(*this));
+    LocalStats::init();
+    Mutex.init();
+    StatsList = {};
     initLinkerInitialized();
   }