Update:
This doesn’t seem to have anything to do with MKL. Just linking with all the boost libraries is enough to cause this. I was able to repro this with just a few files. I am fairly certain this is because of some issue with linking incorrect libraries. Please let me know. I realize that I don’t need all these libraries for the simple test cases I have written.
My g++ version is 4.4.6
Boost version 1.63
File1:
// cat mklmain.cpp
#define BOOST_ALL_DYN_LINK
#define BOOST_TEST_MAIN
#include <boost/test/included/unit_test.hpp>
File2:
// cat mkl1.cpp
#include <boost/test/unit_test.hpp>
#include "logging-helper.h"
BOOST_FIXTURE_TEST_SUITE(mkltest1, Fixture)
BOOST_AUTO_TEST_CASE(math_test_functions1)
{
BOOST_LOG_SEV(lg, trace) << "Starting test case for mkl test 1";
float dot = 3;
BOOST_TEST(dot == 3);
BOOST_LOG_SEV(lg, trace) << "Ending test case for mkl test 1";
}
BOOST_AUTO_TEST_SUITE_END()
File3:
// cat mkl2.cpp
#include <boost/test/unit_test.hpp>
#include "logging-helper.h"
BOOST_FIXTURE_TEST_SUITE(mkltest2, Fixture)
BOOST_AUTO_TEST_CASE(math_test_functions2)
{
BOOST_LOG_SEV(lg, trace) << "Starting test case for mkl test 2";
float dot = 3;
BOOST_TEST(dot == 3);
BOOST_LOG_SEV(lg, trace) << "Ending test case for mkl test 2";
}
BOOST_AUTO_TEST_SUITE_END()
File4:
// cat logging-helper.h
// I realize that not all these headers are necessary. Was trying out different things.
#pragma once
#define BOOST_LOG_DYN_LINK 1
#include <boost/move/utility_core.hpp>
#include <boost/log/sources/logger.hpp>
#include <boost/log/sources/record_ostream.hpp>
#include <boost/log/sources/global_logger_storage.hpp>
#include <boost/log/utility/setup/file.hpp>
#include <boost/log/utility/setup/console.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/sinks/text_file_backend.hpp>
#include <boost/log/sources/severity_logger.hpp>
namespace logging = boost::log;
namespace src = boost::log::sources;
namespace sinks = boost::log::sinks;
namespace keywords = boost::log::keywords;
using namespace logging::trivial;
class Fixture
{
public:
src::severity_logger<severity_level> lg;
Fixture(){
logging::core::get()->remove_all_sinks();
logging::add_console_log
(
std::cout,
keywords::format = "[%TimeStamp%]: %Message%"
);
logging::add_common_attributes();
}
};
My compile/link line is this
g++ -I/home/anandrs/Downloads/boost_1_63_0 -L/home/anandrs/Downloads/boost_1_63_0/stage/lib mkl1.cpp mkl2.cpp mklmain.cpp -lboost_prg_exec_monitor -lboost_unit_test_framework -lboost_context -lboost_locale -lboost_log -lboost_log_setup -lboost_timer -lboost_type_erasure -lboost_wave -lboost_chrono -lboost_filesystem -lboost_graph -lboost_random -lboost_thread -lboost_wserialization -lboost_atomic -lboost_container -lboost_date_time -lboost_iostreams -lboost_math_c99 -lboost_math_c99f -lboost_math_c99l -lboost_math_tr1 -lboost_math_tr1f -lboost_math_tr1l -lboost_program_options -lboost_regex -lboost_serialization -lboost_signals -lboost_system -lboost_exception -lboost_test_exec_monitor -o BoostMKL
valgrind ./BoostMKL
==83998== Memcheck, a memory error detector
==83998== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==83998== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==83998== Command: ./BoostMKL
==83998==
Running 2 test cases...
[2017-02-23 10:11:04.603945]: Starting test case for mkl test 2
[2017-02-23 10:11:04.759958]: Ending test case for mkl test 2
[2017-02-23 10:11:04.824863]: Starting test case for mkl test 1
[2017-02-23 10:11:04.830820]: Ending test case for mkl test 1
*** No errors detected
==83998== Invalid read of size 4
==83998== at 0x93124B6: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib64/libstdc++.so.6.0.13)
==83998== by 0x9A4AEBC: __cxa_finalize (in /lib64/
libc-2.12.so)
==83998== by 0x5083745: ??? (in /local/home/anandrs/Downloads/boost_1_63_0/stage/lib/libboost_unit_test_framework.so.1.63.0)
==83998== by 0x50DBE00: ??? (in /local/home/anandrs/Downloads/boost_1_63_0/stage/lib/libboost_unit_test_framework.so.1.63.0)
==83998== by 0x9A33D63: (below main) (in /lib64/
libc-2.12.so)
==83998== Address 0xa1d4cd0 is 16 bytes inside a block of size 32 free'd
==83998== at 0x4C26FD6: operator delete(void*) (vg_replace_malloc.c:480)
==83998== by 0x93124C8: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib64/libstdc++.so.6.0.13)
==83998== by 0x9A33D63: (below main) (in /lib64/
libc-2.12.so)
==83998==
==83998== Invalid free() / delete / delete[] / realloc()
==83998== at 0x4C26FD6: operator delete(void*) (vg_replace_malloc.c:480)
==83998== by 0x93124C8: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib64/libstdc++.so.6.0.13)
==83998== by 0x9A4AEBC: __cxa_finalize (in /lib64/
libc-2.12.so)
==83998== by 0x5083745: ??? (in /local/home/anandrs/Downloads/boost_1_63_0/stage/lib/libboost_unit_test_framework.so.1.63.0)
==83998== by 0x50DBE00: ??? (in /local/home/anandrs/Downloads/boost_1_63_0/stage/lib/libboost_unit_test_framework.so.1.63.0)
==83998== by 0x9A33D63: (below main) (in /lib64/
libc-2.12.so)
==83998== Address 0xa1d4cc0 is 0 bytes inside a block of size 32 free'd
==83998== at 0x4C26FD6: operator delete(void*) (vg_replace_malloc.c:480)
==83998== by 0x93124C8: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib64/libstdc++.so.6.0.13)
==83998== by 0x9A33D63: (below main) (in /lib64/
libc-2.12.so)
==83998==
==83998==
==83998== HEAP SUMMARY:
==83998== in use at exit: 1,552 bytes in 34 blocks
==83998== total heap usage: 3,704 allocs, 3,698 frees, 221,397 bytes allocated
==83998==
==83998== LEAK SUMMARY:
==83998== definitely lost: 1,032 bytes in 28 blocks
==83998== indirectly lost: 0 bytes in 0 blocks
==83998== possibly lost: 0 bytes in 0 blocks
==83998== still reachable: 520 bytes in 6 blocks
==83998== suppressed: 0 bytes in 0 blocks
==83998== Rerun with --leak-check=full to see details of leaked memory
==83998==
==83998== For counts of detected and suppressed errors, rerun with: -v
==83998== ERROR SUMMARY: 112 errors from 2 contexts (suppressed: 6 from 6)
Thanks,
Anand