[PATCH] D77902: [scudo][standalone] Work with -Werror=class-memaccess

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 10 13:59:01 PDT 2020


cryptoad created this revision.
cryptoad added reviewers: pcc, hctim.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77902

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


Index: compiler-rt/lib/scudo/standalone/stats.h
===================================================================
--- compiler-rt/lib/scudo/standalone/stats.h
+++ compiler-rt/lib/scudo/standalone/stats.h
@@ -58,7 +58,9 @@
 public:
   void initLinkerInitialized() {}
   void init() {
-    memset(this, 0, sizeof(*this));
+    LocalStats::init();
+    Mutex.init();
+    StatsList = {};
     initLinkerInitialized();
   }
 
Index: compiler-rt/lib/scudo/standalone/quarantine.h
===================================================================
--- compiler-rt/lib/scudo/standalone/quarantine.h
+++ compiler-rt/lib/scudo/standalone/quarantine.h
@@ -187,7 +187,12 @@
     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: compiler-rt/lib/scudo/standalone/mutex.h
===================================================================
--- compiler-rt/lib/scudo/standalone/mutex.h
+++ compiler-rt/lib/scudo/standalone/mutex.h
@@ -22,7 +22,7 @@
 
 class HybridMutex {
 public:
-  void init() { memset(this, 0, sizeof(*this)); }
+  void init() { M = {}; }
   bool tryLock();
   NOINLINE void lock() {
     if (LIKELY(tryLock()))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77902.256653.patch
Type: text/x-patch
Size: 1376 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200410/9bf4afc4/attachment.bin>


More information about the llvm-commits mailing list