tst2005googlecode / re2

Automatically exported from code.google.com/p/re2
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

Suppress MemorySanitizer warnings in sparse_set and sparse_array #77

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Attached patch zero-fills sparse set and array memory to avoid warnings about 
uninitialized data access. Existing code does it for Valgrind, the patch 
extends this logic to MSan.

There is also one case in sparse_array resize method where memory was not 
zero-filled enough. Also fixed in the patch.

Original issue reported on code.google.com by euge...@google.com on 21 Mar 2013 at 9:22

Attachments:

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 975db9909185.

Original comment by rsc@swtch.com on 10 Jan 2014 at 1:49

GoogleCodeExporter commented 9 years ago
I believe you missed this chunk in the patch:

@@ -273,11 +274,16 @@
     if (sparse_to_dense_) {
       memmove(a, sparse_to_dense_, max_size_*sizeof a[0]);
       // Don't need to zero the memory but appease Valgrind.
-      if (valgrind_) {
+      if (zero_memory_) {
         for (int i = max_size_; i < new_max_size; i++)
           a[i] = 0xababababU;
       }
       delete[] sparse_to_dense_;
+    } else {
+      if (zero_memory_) {
+        for (int i = 0; i < new_max_size; i++)
+          a[i] = 0xababababU;
+      }
     }

The code in SparseArray<Value>::resize zero-initializes part of 
sparse_to_dense_ if it is reallocated, but does nothing if it is allocated for 
the first time.

Original comment by euge...@google.com on 30 Jan 2014 at 1:37

GoogleCodeExporter commented 9 years ago
Filed as https://code.google.com/p/re2/issues/detail?id=106

Original comment by euge...@google.com on 7 Feb 2014 at 10:54