[Boost-users] segfault using boost test

706 views
Skip to first unread message

David M. Lee

unread,
Nov 8, 2010, 3:19:33 PM11/8/10
to boost...@lists.boost.org
I'm consistently getting segfaults trying to use boost test on my Mac.  The test works fine on Linux.

This is Mac is running Snow Leopard.  I compiled boost using Homebrew (http://mxcl.github.com/homebrew/; seehttps://github.com/mxcl/homebrew/blob/master/Library/Formula/boost.rb for the build formula), but I've also tried building Boost myself with the same results.

Any help figuring this out would be greatly appreciated!

Here's the test I'm running:

#define BOOST_TEST_MODULE simple
#include <boost/test/included/unit_test.hpp>

BOOST_AUTO_TEST_CASE(testSimple)
{
   BOOST_CHECK_EQUAL(true, true);
}

Here's the backtrace:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
0x0000000100265ccc in boost::unit_test::framework::get ()
(gdb) bt
#0  0x0000000100265ccc in boost::unit_test::framework::get ()
#1  0x0000000100270855 in boost::unit_test::results_collector_t::assertion_result ()
#2  0x00000001000242cf in boost::unit_test::framework::assertion_result ()
#3  0x00000001000262a6 in boost::test_tools::tt_detail::check_impl ()
#4  0x000000010006aa01 in boost::test_tools::tt_detail::check_frwd<boost::test_tools::tt_detail::equal_impl_frwd, bool, bool> ()
#5  0x0000000100026409 in testSimple::test_method ()
#6  0x0000000100026468 in testSimple_invoker ()
#7  0x000000010004056d in boost::unit_test::ut_detail::invoker<boost::unit_test::ut_detail::unused>::invoke<void (*)()> ()
#8  0x0000000100040591 in boost::unit_test::ut_detail::callback0_impl_t<boost::unit_test::ut_detail::unused, void (*)()>::invoke ()
#9  0x000000010005bf38 in boost::unit_test::callback0<boost::unit_test::ut_detail::unused>::operator() ()
#10 0x0000000100014698 in boost::unit_test::(anonymous namespace)::zero_return_wrapper_t<boost::unit_test::callback0<boost::unit_test::ut_detail::unused> >::operator() ()
#11 0x00000001000146b9 in boost::unit_test::ut_detail::invoker<int>::invoke<boost::unit_test::(anonymous namespace)::zero_return_wrapper_t<boost::unit_test::callback0<boost::unit_test::ut_detail::unused> > > ()
#12 0x00000001000146d9 in boost::unit_test::ut_detail::callback0_impl_t<int, boost::unit_test::(anonymous namespace)::zero_return_wrapper_t<boost::unit_test::callback0<boost::unit_test::ut_detail::unused> > >::invoke ()
#13 0x000000010005c65c in boost::unit_test::callback0<int>::operator() ()
#14 0x000000010005c6a7 in boost::detail::do_invoke<boost::scoped_ptr<boost::detail::translate_exception_base>, boost::unit_test::callback0<int> > ()
#15 0x00000001000206f1 in boost::execution_monitor::catch_signals ()
#16 0x00000001000218da in boost::execution_monitor::execute ()
#17 0x00000001000240a0 in boost::unit_test::unit_test_monitor_t::execute_and_translate ()
#18 0x000000010006b78d in boost::unit_test::framework_impl::visit ()
#19 0x0000000100008b2e in boost::unit_test::traverse_test_tree ()
#20 0x0000000100023753 in boost::unit_test::traverse_test_tree ()
#21 0x00000001000233a8 in boost::unit_test::traverse_test_tree ()
#22 0x000000010002376a in boost::unit_test::traverse_test_tree ()
#23 0x000000010002aad6 in boost::unit_test::framework::run ()
#24 0x000000010002ae39 in boost::unit_test::unit_test_main ()
#25 0x000000010002b0c2 in main ()

Thanks!
dave
<><

--
David M. Lee
Digium, Inc. | Software Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at:  www.digium.com  & www.asterisk.org

David M. Lee

unread,
Nov 9, 2010, 1:03:50 AM11/9/10
to boost...@lists.boost.org
On Nov 8, 2010, at 2:19 PM, David M. Lee wrote:

> I'm consistently getting segfaults trying to use boost test on my Mac. The test works fine on Linux.


Even stranger: I only get the segfault if I link against unit_test_framework.

dave
<><


_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Jürgen Hunold

unread,
Nov 9, 2010, 10:27:43 AM11/9/10
to boost...@lists.boost.org
Hi Davie,

On Monday, 8. November 2010 21:19:33 David M.Lee wrote:
> Here's the test I'm running:
>
> #define BOOST_TEST_MODULE simple
> #include <boost/test/included/unit_test.hpp>

Why do you use the "included" version of Boost.Test anyway?

> Even stranger: I only get the segfault if I link against
> unit_test_framework.

Yes, this is a classical ODR violation. You get one Boost.Test library built
by "included" and a second instance linked in. And all bets are off.

Either use the "included" variant or link against the lib.

The correct #include for linking against the library is

#include <boost/test/unit_test.hpp>

Yours,

Jürgen
--
* Dipl.-Math. Jürgen Hunold ! Ingenieurgesellschaft für
* voice: ++49 511 262926 57 ! Verkehrs- und Eisenbahnwesen mbH
* fax : ++49 511 262926 99 ! Lister Straße 15
* juergen...@ivembh.de ! www.ivembh.de
*
* Geschäftsführer: ! Sitz des Unternehmens: Hannover
* Prof. Dr.-Ing. Thomas Siefer ! Amtsgericht Hannover, HRB 56965
* PD Dr.-Ing. Alfons Radtke !

David M. Lee

unread,
Nov 9, 2010, 11:46:35 AM11/9/10
to boost...@lists.boost.org

On Nov 9, 2010, at 12:03 AM, David M. Lee wrote:

On Nov 8, 2010, at 2:19 PM, David M. Lee wrote:

I'm consistently getting segfaults trying to use boost test on my Mac.  The test works fine on Linux.


Even stranger: I only get the segfault if I link against unit_test_framework.

dave
<><


If I #include <boost/test/unit_test.hpp>, I get a linker error:

g++ -o simple-test simple-test.cpp -lboost_unit_test_framework
Undefined symbols:
  "_main", referenced from:
      start in crt1.10.6.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

dave
<><


Jürgen Hunold

unread,
Nov 9, 2010, 2:50:25 PM11/9/10
to boost...@lists.boost.org
Hi Dave,

On Tuesday, 9. November 2010 17:46:35 David M.Lee wrote:
> If I #include <boost/test/unit_test.hpp>, I get a linker error:
>
> g++ -o simple-test simple-test.cpp -lboost_unit_test_framework
> Undefined symbols:
> "_main", referenced from:
> start in crt1.10.6.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status

main() is normally defined by BOOST_TEST_MODULE if BOOST_TEST_DYN_LINK is also
defined. Seems the latter is missing on your command line.

#define BOOST_TEST_MODULE simple
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_CASE(testSimple)
{
BOOST_CHECK_EQUAL(true, true);
}

If this does not help, please provide a complete testcase. (bjam driven
preferred).

Yours,

Jürgen
--
* Dipl.-Math. Jürgen Hunold ! Ingenieurgesellschaft für
* voice: ++49 511 262926 57 ! Verkehrs- und Eisenbahnwesen mbH
* fax : ++49 511 262926 99 ! Lister Straße 15
* juergen...@ivembh.de ! www.ivembh.de
*
* Geschäftsführer: ! Sitz des Unternehmens: Hannover
* Prof. Dr.-Ing. Thomas Siefer ! Amtsgericht Hannover, HRB 56965
* PD Dr.-Ing. Alfons Radtke !

_______________________________________________

Reply all
Reply to author
Forward
0 new messages