Opened 10 years ago

Closed 10 years ago

#7512 closed Bugs (invalid)

Boost.Test segmentation fault when built with clang on Mac OS X.

Reported by: manphiz@… Owned by: Gennadiy Rozental
Milestone: To Be Determined Component: test
Version: Boost 1.51.0 Severity: Problem
Keywords: Cc:

Description

Mac OS X 10.8.2, Xcode 4.5.1

$ clang -v Apple clang version 4.1 (tags/Apple/clang-421.11.65) (based on LLVM 3.1svn) Target: x86_64-apple-darwin12.2.0 Thread model: posix

Boost is built with clang without -std=c++11.

The problem is shown below:

$ cat boost_test_segfault.cc 
#define BOOST_TEST_MODULE test

#include <boost/test/included/unit_test.hpp>

BOOST_AUTO_TEST_CASE( test1 )
{
    BOOST_CHECK(true);
}
$ clang++ -g -Wall -I/opt/homebrew/include boost_test_segfault.cc -L/opt/homebrew/lib -lboost_unit_test_framework-mt
In file included from boost_test_segfault.cc:3:
In file included from /opt/homebrew/include/boost/test/included/unit_test.hpp:20:
In file included from /opt/homebrew/include/boost/test/impl/framework.ipp:29:
In file included from /opt/homebrew/include/boost/test/test_tools.hpp:21:
/opt/homebrew/include/boost/test/floating_point_comparison.hpp:251:25: warning: unused variable 'check_is_close' [-Wunused-variable]
check_is_close_t const& check_is_close = unit_test::ut_detail::static_constant<check_is_close_t>::value;
                        ^
/opt/homebrew/include/boost/test/floating_point_comparison.hpp:273:25: warning: unused variable 'check_is_small' [-Wunused-variable]
check_is_small_t const& check_is_small = unit_test::ut_detail::static_constant<check_is_small_t>::value;
                        ^
2 warnings generated.
$ ./a.out
Running 1 test case...
Segmentation fault: 11

A detailed gdb session with "bt full" is attached.

Also, on a relevant post on stackoverflow (http://stackoverflow.com/questions/12695625/boost-test-crashes-on-exit-with-clang-4-1-llvm-3-1svn) the user tried with building boost using clang with -std=c++11 -stdlib=libc++ and compile the test code with the same flag and the executable doesn't crash anymore. But I haven't tested that. I also tried to build the test program with llvm g++, but it runs with the same error.

Attachments (1)

gdb.log (18.2 KB ) - added by manphiz@… 10 years ago.

Download all attachments as: .zip

Change History (4)

by manphiz@…, 10 years ago

Attachment: gdb.log added

comment:1 by manphiz@…, 10 years ago

After some testings, it looks like all compilers on Mac OS X (apple-gcc 4.2.1, llvm-gcc 4.2.1, clang 4.1) are affected.

comment:2 by manphiz@…, 10 years ago

OK, it seems that I'm not using it right. It seems that at least on Mac OS X one should just use dynamic library or single header, but not both at the same time. Using each flavor the test program runs just fine. So please feel free to close this ticket.

comment:3 by Gennadiy Rozental, 10 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.