OPM / opm-common

Common components for OPM, in particular build system (cmake).
http://www.opm-project.org
GNU General Public License v3.0
34 stars 111 forks source link

build fails with `-fsanitze=address` #657

Open andlaus opened 5 years ago

andlaus commented 5 years ago

trying to build with -fsanitize=address unadvertedly kills the code generator, probably because of a memory leak. this is for a system with GCC 8.2.1:

make
[...]
[ 18%] Generating tmp_gen/ParserKeywords.cpp, tmp_gen/inlinekw.cpp
Updated source file written to: /home/and/src/opm-common/build-cmake/tmp_gen/ParserKeywords.cpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/A.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/B.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/C.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/D.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/E.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/F.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/G.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/H.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/I.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/J.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/L.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/M.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/N.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/O.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/P.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/Q.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/R.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/S.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/T.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/U.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/V.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/W.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/Z.hpp
Updated header file written to: /home/and/src/opm-common/build-cmake/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords.hpp

=================================================================
==71368==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x7f68276e6ef0 in malloc (/usr/lib64/libasan.so.5+0xebef0)
    #1 0x7f6825b03f08 in get_num_procs (/usr/lib64/libopenblas_pthreads.so.0+0x32af08)

SUMMARY: AddressSanitizer: 8 byte(s) leaked in 1 allocation(s).
gmake[2]: *** [CMakeFiles/opmcommon.dir/build.make:526: tmp_gen/ParserKeywords.cpp] Error 1
joakim-hove commented 5 years ago

I have looked briefly into this - adding -fsantize=address to CMAKE_CXX_FLAGS "works on my machine" - I have Ubuntu 16.04 with gcc 5.4.0.

As for the bug you report it seems to me to originate in your BLAS implementation - not very much we can do with that?

andlaus commented 5 years ago

yep, there's probably a memleak in one of the libraries which the code generator links to (my openblas library comes in version 0.3.5). From a downstream user's perspective the difference is rather irrelevant because the build fails...