You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/08/27 22:10:03 UTC

[GitHub] KellenSunderland closed pull request #12370: WIP: Add clang Sanitizers to CI

KellenSunderland closed pull request #12370: WIP: Add clang Sanitizers to CI
URL: https://github.com/apache/incubator-mxnet/pull/12370
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/CMakeLists.txt b/CMakeLists.txt
index adff5333665..485f83262f2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,6 +38,7 @@ mxnet_option(BUILD_CPP_EXAMPLES   "Build cpp examples" ON)
 mxnet_option(INSTALL_EXAMPLES     "Install the example source files." OFF)
 mxnet_option(USE_SIGNAL_HANDLER   "Print stack traces on segfaults." OFF)
 mxnet_option(USE_TENSORRT         "Enable infeference optimization with TensorRT." OFF)
+mxnet_option(USE_ASAN             "Enable Clang/GCC ASAN sanitizers." OFF)
 
 message(STATUS "CMAKE_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}")
 if(USE_CUDA AND NOT USE_OLDCMAKECUDA)
@@ -62,7 +63,6 @@ else()
   project(mxnet C CXX)
 endif()
 
-
 if(MSVC)
   set(SYSTEM_ARCHITECTURE x86_64)
 else()
@@ -78,7 +78,6 @@ if("$ENV{VERBOSE}" STREQUAL "1")
   set(CMAKE_VERBOSE_MAKEFILE ON)
 endif()
 
-
 if(MSVC)
   add_definitions(-DWIN32_LEAN_AND_MEAN)
   add_definitions(-DDMLC_USE_CXX11)
@@ -285,6 +284,11 @@ else()
   endif()
 endif()
 
+if(USE_ASAN)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=address -shared-libasan")
+  set(CMAKE_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
+endif()
+
 list(APPEND mxnet_LINKER_LIBS ${mshadow_LINKER_LIBS})
 
 foreach(var ${C_CXX_INCLUDE_DIRECTORIES})
diff --git a/Jenkinsfile b/Jenkinsfile
index 0e4aa199a6c..fdfcec87986 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -50,6 +50,13 @@ def python3_ut(docker_container_name) {
   }
 }
 
+// Python 3
+def python3_ut_asan(docker_container_name) {
+  timeout(time: max_time, unit: 'MINUTES') {
+    utils.docker_run(docker_container_name, 'unittest_ubuntu_python3_cpu_asan', false)
+  }
+}
+
 def python3_ut_mkldnn(docker_container_name) {
   timeout(time: max_time, unit: 'MINUTES') {
     utils.docker_run(docker_container_name, 'unittest_ubuntu_python3_cpu_mkldnn', false)
@@ -454,7 +461,7 @@ core_logic: {
           try {
             utils.init_git()
             utils.unpack_lib('cpu_debug', mx_cmake_lib_debug)
-            python3_ut('ubuntu_cpu')
+            python3_ut_asan('ubuntu_cpu')
           } finally {
             utils.collect_test_results_unix('nosetests_unittest.xml', 'nosetests_python3_cpu_debug_unittest.xml')
             utils.collect_test_results_unix('nosetests_quantization.xml', 'nosetests_python3_cpu_debug_quantization.xml')
diff --git a/ci/docker/runtime_functions.sh b/ci/docker/runtime_functions.sh
index 1e38ec48e6c..b30c885e0cc 100755
--- a/ci/docker/runtime_functions.sh
+++ b/ci/docker/runtime_functions.sh
@@ -319,6 +319,10 @@ build_ubuntu_cpu_openblas() {
 
 build_ubuntu_cpu_cmake_debug() {
     set -ex
+
+    export CXX=clang++-6.0
+    export CC=clang-6.0
+
     pushd .
     cd /work/build
     cmake \
@@ -326,9 +330,10 @@ build_ubuntu_cpu_cmake_debug() {
         -DCMAKE_C_COMPILER_LAUNCHER=ccache \
         -DUSE_CUDA=OFF \
         -DUSE_MKL_IF_AVAILABLE=OFF \
-        -DUSE_OPENMP=OFF \
+        -DUSE_OPENMP=ON \
         -DUSE_OPENCV=ON \
         -DCMAKE_BUILD_TYPE=Debug \
+        -DUSE_ASAN=ON \
         -G Ninja \
         /work/mxnet
 
@@ -598,6 +603,17 @@ unittest_ubuntu_python3_cpu() {
     nosetests-3.4 $NOSE_COVERAGE_ARGUMENTS --with-xunit --xunit-file nosetests_quantization.xml --verbose tests/python/quantization
 }
 
+unittest_ubuntu_python3_cpu_asan() {
+    set -ex
+    export PYTHONPATH=./python/
+    export MXNET_MKLDNN_DEBUG=1  # Ignored if not present
+    export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0
+    export PATH=$PATH:/usr/lib/llvm-6.0/bin/ # Enable clang de-mangling of ASAN output
+    export LD_PRELOAD=$LD_PRELOAD:/usr/lib/llvm-6.0/lib/clang/6.0.1/lib/linux/libclang_rt.asan-x86_64.so
+    nosetests-3.4 $NOSE_COVERAGE_ARGUMENTS --with-xunit --xunit-file nosetests_unittest.xml --verbose tests/python/unittest
+    nosetests-3.4 $NOSE_COVERAGE_ARGUMENTS --with-xunit --xunit-file nosetests_quantization.xml --verbose tests/python/quantization
+}
+
 unittest_ubuntu_python3_cpu_mkldnn() {
     set -ex
     export PYTHONPATH=./python/


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services