Commit 0195d52c authored by earthdok@chromium.org's avatar earthdok@chromium.org

Patch re2 to support MSan.

BUG=178409
R=eugenis@chromium.org
TBR=cpu@chromium.org

Review URL: https://codereview.chromium.org/149723005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247998 0039d316-1c4b-4281-b951-d872f2087c98
parent e3440b10
...@@ -23,3 +23,7 @@ Local Modifications (to be applied in this order): ...@@ -23,3 +23,7 @@ Local Modifications (to be applied in this order):
https://code.google.com/p/re2/issues/detail?id=76 https://code.google.com/p/re2/issues/detail?id=76
- Memory optimization for filtered trees - Memory optimization for filtered trees
(patches/re2-memory-optimization.patch) (patches/re2-memory-optimization.patch)
- Prevent unwanted reports from MemorySanitizer. Note: there's an upstream fix
for this (https://code.google.com/p/re2/issues/detail?id=77) which is rendered
ineffective by patches/remove-valgrind-code.patch
(patches/re2-msan.patch)
diff --git a/third_party/re2/util/sparse_array.h b/third_party/re2/util/sparse_array.h
index 3e33f89..4ee5c94 100644
--- a/third_party/re2/util/sparse_array.h
+++ b/third_party/re2/util/sparse_array.h
@@ -231,7 +231,8 @@ class SparseArray {
template<typename Value>
SparseArray<Value>::SparseArray()
- : size_(0), max_size_(0), sparse_to_dense_(NULL), dense_(), valgrind_(RunningOnValgrind()) {}
+ : size_(0), max_size_(0), sparse_to_dense_(NULL), dense_(),
+ valgrind_(RunningOnValgrindOrMemorySanitizer()) {}
// IndexValue pairs: exposed in SparseArray::iterator.
template<typename Value>
@@ -418,7 +419,7 @@ void SparseArray<Value>::create_index(int i) {
template<typename Value> SparseArray<Value>::SparseArray(int max_size) {
max_size_ = max_size;
sparse_to_dense_ = new int[max_size];
- valgrind_ = RunningOnValgrind();
+ valgrind_ = RunningOnValgrindOrMemorySanitizer();
dense_.resize(max_size);
// Don't need to zero the new memory, but appease Valgrind.
if (valgrind_) {
diff --git a/third_party/re2/util/sparse_set.h b/third_party/re2/util/sparse_set.h
index 165dd09..4a324d7 100644
--- a/third_party/re2/util/sparse_set.h
+++ b/third_party/re2/util/sparse_set.h
@@ -54,13 +54,14 @@ namespace re2 {
class SparseSet {
public:
SparseSet()
- : size_(0), max_size_(0), sparse_to_dense_(NULL), dense_(NULL), valgrind_(RunningOnValgrind()) {}
+ : size_(0), max_size_(0), sparse_to_dense_(NULL), dense_(NULL),
+ valgrind_(RunningOnValgrindOrMemorySanitizer()) {}
SparseSet(int max_size) {
max_size_ = max_size;
sparse_to_dense_ = new int[max_size];
dense_ = new int[max_size];
- valgrind_ = RunningOnValgrind();
+ valgrind_ = RunningOnValgrindOrMemorySanitizer();
// Don't need to zero the memory, but do so anyway
// to appease Valgrind.
if (valgrind_) {
diff --git a/third_party/re2/util/util.h b/third_party/re2/util/util.h
index de1ef5b..49159c2 100644
--- a/third_party/re2/util/util.h
+++ b/third_party/re2/util/util.h
@@ -129,6 +129,14 @@ static inline uint64 Hash64StringWithSeed(const char* s, int len, uint32 seed) {
return ((uint64)x << 32) | y;
}
+inline bool RunningOnValgrindOrMemorySanitizer() {
+#if defined(MEMORY_SANITIZER)
+ return true;
+#else
+ return RunningOnValgrind();
+#endif
+}
+
} // namespace re2
#include "util/arena.h"
...@@ -231,7 +231,8 @@ class SparseArray { ...@@ -231,7 +231,8 @@ class SparseArray {
template<typename Value> template<typename Value>
SparseArray<Value>::SparseArray() SparseArray<Value>::SparseArray()
: size_(0), max_size_(0), sparse_to_dense_(NULL), dense_(), valgrind_(RunningOnValgrind()) {} : size_(0), max_size_(0), sparse_to_dense_(NULL), dense_(),
valgrind_(RunningOnValgrindOrMemorySanitizer()) {}
// IndexValue pairs: exposed in SparseArray::iterator. // IndexValue pairs: exposed in SparseArray::iterator.
template<typename Value> template<typename Value>
...@@ -418,7 +419,7 @@ void SparseArray<Value>::create_index(int i) { ...@@ -418,7 +419,7 @@ void SparseArray<Value>::create_index(int i) {
template<typename Value> SparseArray<Value>::SparseArray(int max_size) { template<typename Value> SparseArray<Value>::SparseArray(int max_size) {
max_size_ = max_size; max_size_ = max_size;
sparse_to_dense_ = new int[max_size]; sparse_to_dense_ = new int[max_size];
valgrind_ = RunningOnValgrind(); valgrind_ = RunningOnValgrindOrMemorySanitizer();
dense_.resize(max_size); dense_.resize(max_size);
// Don't need to zero the new memory, but appease Valgrind. // Don't need to zero the new memory, but appease Valgrind.
if (valgrind_) { if (valgrind_) {
......
...@@ -54,13 +54,14 @@ namespace re2 { ...@@ -54,13 +54,14 @@ namespace re2 {
class SparseSet { class SparseSet {
public: public:
SparseSet() SparseSet()
: size_(0), max_size_(0), sparse_to_dense_(NULL), dense_(NULL), valgrind_(RunningOnValgrind()) {} : size_(0), max_size_(0), sparse_to_dense_(NULL), dense_(NULL),
valgrind_(RunningOnValgrindOrMemorySanitizer()) {}
SparseSet(int max_size) { SparseSet(int max_size) {
max_size_ = max_size; max_size_ = max_size;
sparse_to_dense_ = new int[max_size]; sparse_to_dense_ = new int[max_size];
dense_ = new int[max_size]; dense_ = new int[max_size];
valgrind_ = RunningOnValgrind(); valgrind_ = RunningOnValgrindOrMemorySanitizer();
// Don't need to zero the memory, but do so anyway // Don't need to zero the memory, but do so anyway
// to appease Valgrind. // to appease Valgrind.
if (valgrind_) { if (valgrind_) {
......
...@@ -129,6 +129,14 @@ static inline uint64 Hash64StringWithSeed(const char* s, int len, uint32 seed) { ...@@ -129,6 +129,14 @@ static inline uint64 Hash64StringWithSeed(const char* s, int len, uint32 seed) {
return ((uint64)x << 32) | y; return ((uint64)x << 32) | y;
} }
inline bool RunningOnValgrindOrMemorySanitizer() {
#if defined(MEMORY_SANITIZER)
return true;
#else
return RunningOnValgrind();
#endif
}
} // namespace re2 } // namespace re2
#include "util/arena.h" #include "util/arena.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment