]> granicus.if.org Git - llvm/commitdiff
[LibFuzzer] Fix some unit test crashes on OSX.
authorDan Liew <dan@su-root.co.uk>
Fri, 10 Jun 2016 05:33:07 +0000 (05:33 +0000)
committerDan Liew <dan@su-root.co.uk>
Fri, 10 Jun 2016 05:33:07 +0000 (05:33 +0000)
This fixes the following unit tests:

FuzzerDictionary.ParseOneDictionaryEntry
FuzzerDictionary.ParseDictionaryFile

The issue appears to be mixing non-ASan-ified code (LibFuzzer) and
ASan-ified code (the unittest) as the tests would pass fine if
everything was built with ASan enabled.

I believe the issue is that different implementations of std::vector<>
are being used in LibFuzzer and outside LibFuzzer (in the unittests).
For Libcxx (I've not seen the issue manifest for libstdc++) we can disable
the ASanified std::vector<> by definining the ``_LIBCPP_HAS_NO_ASAN`` macro.
Doing this fixes the tests on OSX.

Differential Revision: http://reviews.llvm.org/D21049

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272374 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Fuzzer/test/FuzzerUnittest.cpp

index 91ac9a73c172e638d474c8ad7c793c1544022aa2..36d13a0346dcc014042f6d16fa3b541107fa473e 100644 (file)
@@ -1,6 +1,10 @@
 // This file is distributed under the University of Illinois Open Source
 // License. See LICENSE.TXT for details.
 
+// Avoid ODR violations (LibFuzzer is built without ASan and this test is built
+// with ASan) involving C++ standard library types when using libcxx.
+#define _LIBCPP_HAS_NO_ASAN
+
 #include "FuzzerInternal.h"
 #include "gtest/gtest.h"
 #include <memory>