Boost logo

Boost Users :

Subject: [Boost-users] [Test]: Problem with simple Boost.Test
From: Damien Kick (dkick_at_[hidden])
Date: 2013-06-17 17:23:21


I'm trying to get what I think should be a simple example of
Boost.Test (Boost 1.53) to work but I'm getting a segmentation fault,
having used other of the Boost libraries from the same build/install
of 1.53 without any problems. Am I doing anything obviously wrong?
Thanks in advance for any help.

$ cat test/cma.cpp
#define BOOST_TEST_MODULE cma
#include <boost/test/unit_test.hpp>

#include <iostream>
#include <ostream>

BOOST_AUTO_TEST_CASE(sanity)
{
    std::clog << "Test the world!\n";
}
$ make check
[100%] Building CXX object CMakeFiles/test-cma.dir/test/cma.cpp.o
Linking CXX executable test-cma
[100%] Built target test-cma
[100%] Built target check
$ env DYLD_LIBRARY_PATH=${TARGET}/lib ./test-cma
Running 1 test case...
Test the world!
Segmentation fault: 11
$

Here are some more details. I'm trying this on Mac with GCC.

$ uname -a
Darwin Damien-Kicks-MacBook-Pro.local 12.4.0 Darwin Kernel Version 12.4.0: \
Wed May 1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64
$ ${CXX} --version
g++ (GCC) 4.8.0
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I've compiled my build/install of Boost 1.53 with --std=c++0x. Again,
I've used other libraries from this same build/install (DateTime,
Filesystem, Random, Regex, Serialization, System, Thread), so I don't
think that the problem is my use of --std=c++0x in and of itself.

$ ${CXX} -c --std=c++0x -g -I${TARGET}/include cma.cpp -o cma.o
$ ${CXX} --std=c++0x -g cma.o ${TARGET}/lib/libboost_test_exec_monitor.a \
${TARGET}/lib/libboost_unit_test_framework.dylib -o cma
$ env DYLD_LIBRARY_PATH=${TARGET}/lib ./cma
Running 1 test case...
Test the world!
Segmentation fault: 11
$

If I run this under GDB

(gdb) run
Starting program: cma
Reading symbols for shared libraries ++++.............................. done
Running 1 test case...
Test the world!

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
boost::unit_test::framework::get (id=65536, t=tut_case) at \
impl/framework.ipp:388
388 if( (res->p_type & t) == 0 )
(gdb) bt
#0 boost::unit_test::framework::get (id=65536, t=tut_case) at \
impl/framework.ipp:388
#1 0x0000000100134805 in boost::unit_test::traverse_test_tree \
(suite=@0x100403f10, V=@0x7fff5fbff470) at framework.hpp:73
Previous frame inner to this frame (gdb could not unwind past this frame)
(gdb) print res
$1 = ('boost::unit_test::test_unit' *) 0x0
(gdb)

________________________________

This e-mail and any attachments are confidential. If it is not intended for you, please notify the sender, and please erase and ignore the contents.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net