[Test] Test executable crashes always
Hello, I've made some unit tests with boost test before without issue, but on my latest rather ordinary test, I've been able to get Boost test to crash the executable in debug and release mode when boost test is making a report before terminating. test_exe.exe!boost::unit_test::framework::get(unsigned long id, boost::unit_test::test_unit_type t) Line 1388 C++ test_exe.exe!boost::unit_test::framework::getboost::unit_test::test_unit(unsigned long id) Line 208 C++ test_exe.exe!boost::unit_test::results_reporter::make_report(boost::unit_test::report_level l, unsigned long id) Line 175 C++ test_exe.exe!boost::unit_test::unit_test_main(boost::unit_test::test_suite *(*)(int, char * *) init_func, int argc, char * * argv) Line 235 C++ test_exe.exe!main(int argc, char * * argv) Line 287 C++ That's the default report_level of 'confirm' If I use report_level=short or detailed, I get a similar crash: test_exe.exe!boost::unit_test::framework::get(unsigned long id, boost::unit_test::test_unit_type t) Line 1388 C++ test_exe.exe!boost::unit_test::framework::getboost::unit_test::test_suite(unsigned long id) Line 207 C++ test_exe.exe!boost::unit_test::traverse_test_tree(unsigned long id, boost::unit_test::test_tree_visitor & V, bool ignore_status) Line 365 C++ test_exe.exe!boost::unit_test::results_reporter::make_report(boost::unit_test::report_level l, unsigned long id) Line 185 C++ test_exe.exe!boost::unit_test::unit_test_main(boost::unit_test::test_suite *(*)(int, char * *) init_func, int argc, char * * argv) Line 235 C++ test_exe.exe!main(int argc, char * * argv) Line 287 C++ Here's the get() method: test_unit& get( test_unit_id id, test_unit_type t ) { test_unit* res = impl::s_frk_state().m_test_units[id]; BOOST_TEST_I_ASSRT( (res->p_type & t) != 0, internal_error( "Invalid test unit type" ) ); return *res; } Crash occurs on line 2 of the function. I logged 'res' each time the function is called and many times its valid, but when it runs this one test (by itself or with others), 'res' always ends up being NULL. id seems to always be '1', and t is TUT_ANY (17) if generating a confirmation report or TUT_SUITE (16) if generating a short or detailed report. If I use the option '--report_level=no', then execution does complete fine. I followed through on some process of elimination and it seems to be related to using a fixture? Having no test body still causes the crash. It wasn't until I removed the fixture (and its usage in the body of the test) did the executable not crash. I ensured that I was using the standard fixture model found here: http://www.boost.org/doc/libs/1_64_0/libs/test/doc/html/boost_test/tests_org... OS is Win 7 w/ VS2015 boost is 1.64.0 and was built with: b2 toolset=msvc-14.0 link=static runtime-link=static variant=debug address-model=64 --without-atomic --without-container --without-context --without-coroutine --without-coroutine2 --without-graph --without-graph_parallel --without-iostreams --without-locale --without-math --without-mpi --without-serialization --without-signals --without-type_erasure --without-wave -j4 --abbreviate-paths --without-python -d2 Any help would of something to look at or change would be appreciated. Thanks for your time, Nathan
Le 03.01.18 à 15:39, Nate Widmyer via Boost-users a écrit :
Hello,
I've made some unit tests with boost test before without issue, but on my latest rather ordinary test, I've been able to get Boost test to crash the executable in debug and release mode when boost test is making a report before terminating.
test_exe.exe!boost::unit_test::framework::get(unsigned long id, boost::unit_test::test_unit_type t) Line 1388 C++ test_exe.exe!boost::unit_test::framework::getboost::unit_test::test_unit(unsigned long id) Line 208 C++ test_exe.exe!boost::unit_test::results_reporter::make_report(boost::unit_test::report_level l, unsigned long id) Line 175 C++ test_exe.exe!boost::unit_test::unit_test_main(boost::unit_test::test_suite *(*)(int, char * *) init_func, int argc, char * * argv) Line 235 C++ test_exe.exe!main(int argc, char * * argv) Line 287 C++
That's the default report_level of 'confirm'
If I use report_level=short or detailed, I get a similar crash:
test_exe.exe!boost::unit_test::framework::get(unsigned long id, boost::unit_test::test_unit_type t) Line 1388 C++ test_exe.exe!boost::unit_test::framework::getboost::unit_test::test_suite(unsigned long id) Line 207 C++ test_exe.exe!boost::unit_test::traverse_test_tree(unsigned long id, boost::unit_test::test_tree_visitor & V, bool ignore_status) Line 365 C++ test_exe.exe!boost::unit_test::results_reporter::make_report(boost::unit_test::report_level l, unsigned long id) Line 185 C++ test_exe.exe!boost::unit_test::unit_test_main(boost::unit_test::test_suite *(*)(int, char * *) init_func, int argc, char * * argv) Line 235 C++ test_exe.exe!main(int argc, char * * argv) Line 287 C++
Here's the get() method:
test_unit& get( test_unit_id id, test_unit_type t ) { test_unit* res = impl::s_frk_state().m_test_units[id];
BOOST_TEST_I_ASSRT( (res->p_type & t) != 0, internal_error( "Invalid test unit type" ) );
return *res; }
Crash occurs on line 2 of the function. I logged 'res' each time the function is called and many times its valid, but when it runs this one test (by itself or with others), 'res' always ends up being NULL.
id seems to always be '1', and t is TUT_ANY (17) if generating a confirmation report or TUT_SUITE (16) if generating a short or detailed report.
If I use the option '--report_level=no', then execution does complete fine.
I followed through on some process of elimination and it seems to be related to using a fixture?
Having no test body still causes the crash. It wasn't until I removed the fixture (and its usage in the body of the test) did the executable not crash.
I ensured that I was using the standard fixture model found here:
http://www.boost.org/doc/libs/1_64_0/libs/test/doc/html/boost_test/tests_org...
OS is Win 7 w/ VS2015
boost is 1.64.0 and was built with: b2 toolset=msvc-14.0 link=static runtime-link=static variant=debug address-model=64 --without-atomic --without-container --without-context --without-coroutine --without-coroutine2 --without-graph --without-graph_parallel --without-iostreams --without-locale --without-math --without-mpi --without-serialization --without-signals --without-type_erasure --without-wave -j4 --abbreviate-paths --without-python -d2
Any help would of something to look at or change would be appreciated.
Thanks for your time,
Nathan
From what you described here, it is difficult to say which part is causing the crash. Post your code and I'll try to reproduce on my end.
Raffi
Bonjour Raffi,
I was able to reproduce the crash with this minimal source:
#define BOOST_TEST_MODULE unit_test
#include
Hello,
I've made some unit tests with boost test before without issue, but on my latest rather ordinary test, I've been able to get Boost test to crash the executable in debug and release mode when boost test is making a report before terminating.
test_exe.exe!boost::unit_test::framework::get(unsigned long id, boost::unit_test::test_unit_type t) Line 1388 C++ test_exe.exe!boost::unit_test::framework::getboost::unit_test::test_unit(unsigned long id) Line 208 C++ test_exe.exe!boost::unit_test::results_reporter::make_report(boost::unit_test::report_level l, unsigned long id) Line 175 C++ test_exe.exe!boost::unit_test::unit_test_main(boost::unit_test::test_suite *(*)(int, char * *) init_func, int argc, char * * argv) Line 235 C++ test_exe.exe!main(int argc, char * * argv) Line 287 C++
That's the default report_level of 'confirm'
If I use report_level=short or detailed, I get a similar crash:
test_exe.exe!boost::unit_test::framework::get(unsigned long id, boost::unit_test::test_unit_type t) Line 1388 C++ test_exe.exe!boost::unit_test::framework::getboost::unit_test::test_suite(unsigned long id) Line 207 C++ test_exe.exe!boost::unit_test::traverse_test_tree(unsigned long id, boost::unit_test::test_tree_visitor & V, bool ignore_status) Line 365 C++ test_exe.exe!boost::unit_test::results_reporter::make_report(boost::unit_test::report_level l, unsigned long id) Line 185 C++ test_exe.exe!boost::unit_test::unit_test_main(boost::unit_test::test_suite *(*)(int, char * *) init_func, int argc, char * * argv) Line 235 C++ test_exe.exe!main(int argc, char * * argv) Line 287 C++
Here's the get() method:
test_unit& get( test_unit_id id, test_unit_type t ) { test_unit* res = impl::s_frk_state().m_test_units[id];
BOOST_TEST_I_ASSRT( (res->p_type & t) != 0, internal_error( "Invalid test unit type" ) );
return *res; }
Crash occurs on line 2 of the function. I logged 'res' each time the function is called and many times its valid, but when it runs this one test (by itself or with others), 'res' always ends up being NULL.
id seems to always be '1', and t is TUT_ANY (17) if generating a confirmation report or TUT_SUITE (16) if generating a short or detailed report.
If I use the option '--report_level=no', then execution does complete fine.
I followed through on some process of elimination and it seems to be related to using a fixture?
Having no test body still causes the crash. It wasn't until I removed the fixture (and its usage in the body of the test) did the executable not crash.
I ensured that I was using the standard fixture model found here:
http://www.boost.org/doc/libs/1_64_0/libs/test/doc/html/boost_test/tests_org...
OS is Win 7 w/ VS2015
boost is 1.64.0 and was built with: b2 toolset=msvc-14.0 link=static runtime-link=static variant=debug address-model=64 --without-atomic --without-container --without-context --without-coroutine --without-coroutine2 --without-graph --without-graph_parallel --without-iostreams --without-locale --without-math --without-mpi --without-serialization --without-signals --without-type_erasure --without-wave -j4 --abbreviate-paths --without-python -d2
Any help would of something to look at or change would be appreciated.
Thanks for your time,
Nathan
From what you described here, it is difficult to say which part is causing the crash. Post your code and I'll try to reproduce on my end.
Raffi _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
Le 04.01.18 à 15:13, Nate Widmyer via Boost-users a écrit :
Bonjour Raffi,
I was able to reproduce the crash with this minimal source:
#define BOOST_TEST_MODULE unit_test #include
struct f {
f() { boost::unit_test::master_test_suite_t master_test_suite = boost::unit_test::framework::master_test_suite(); /* crashes later because of this line */ } ~f() { } };
BOOST_FIXTURE_TEST_CASE(sample_test, f) { BOOST_TEST(true); }
I noted the critical line above.
My goal is to access the path of the executable, and that static getter to the master test suite is apparently the right way to get it.
You are not getting a ref but a copy of the master test suite. You should change the line to boost::unit_test::master_test_suite_t& boost::unit_test::framework::master_test_suite();
I've been able to bypass the crash by avoiding keeping the ref as a local variable:
f() { boost::filesystem::path exe_dir = boost::filesystem::system_complete(boost::unit_test::framework::master_test_suite().argv[0]) .remove_filename(); }
In this example, you are properly accessing the master_test_suite by reference.
IMHO it still seems like a bug that a ref returned in the fixture constructor causes a crash later on program termination?
There is a bug in the sense that we still allow for copying the master test suite. I will remove this possibility.
Hope this helps. Thanks again for your time,
Thank you! Raffi
Le 04/01/2018 à 15:22, Raffi Enficiaud via Boost-users a écrit :
Le 04.01.18 à 15:13, Nate Widmyer via Boost-users a écrit :
Bonjour Raffi,
[snip]
In this example, you are properly accessing the master_test_suite by reference.
IMHO it still seems like a bug that a ref returned in the fixture constructor causes a crash later on program termination?
There is a bug in the sense that we still allow for copying the master test suite. I will remove this possibility.
Hope this helps. Thanks again for your time,
Thank you! Raffi
For the record, the master_test_suite_t is not copyable anymore. Best, Raffi
participants (2)
-
Nate Widmyer
-
Raffi Enficiaud