[PATCH] D56107: [sanitizer] Avoid memset call in tsan

Jordan Rupprecht via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 27 11:10:16 PST 2018


rupprecht created this revision.
rupprecht added a reviewer: eugenis.
Herald added subscribers: Sanitizers, llvm-commits, delcypher, kubamracek.

Assigning an array of bools to {false, false, false} can, in certain build configurations, lead to a memset call. Use internal_memset to avoid this.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D56107

Files:
  lib/sanitizer_common/sanitizer_posix.cc


Index: lib/sanitizer_common/sanitizer_posix.cc
===================================================================
--- lib/sanitizer_common/sanitizer_posix.cc
+++ lib/sanitizer_common/sanitizer_posix.cc
@@ -322,7 +322,8 @@
   CHECK_GE(fd, 0);
   if (fd > 2)
     return fd;
-  bool used[3] = {false, false, false};
+  bool used[3];
+  internal_memset(used, 0, sizeof(used));
   while (fd <= 2) {
     used[fd] = true;
     fd = internal_dup(fd);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56107.179566.patch
Type: text/x-patch
Size: 446 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181227/04f3e314/attachment.bin>


More information about the llvm-commits mailing list