Boost logo

Boost Users :

Subject: Re: [Boost-users] BOOST_THROW_EXCEPTION causing Abort Trap
From: Kieran Simpson (kierans777_at_[hidden])
Date: 2011-12-04 05:30:55


The problem was caused by using the MacPorts version of g++. There are
plenty of tickets related to exceptions and Abort Traps in the MP system
(and plenty of examples on Google).

Using the version of g++ that comes with XCode enabled this problem to
go away.

Cheers,

On 23/07/64 5:59 AM, Kieran Simpson wrote:
> I'm trying to use `boost::exception` and have condensed my prototype
> code down to the example in the Boost exception tutorial
> (http://www.boost.org/doc/libs/1_47_0/libs/exception/doc/tutorial_transporting_data.html)
> however when running the code with the `BOOST_THROW_EXCEPTION` macro I
> get an abort from the program.
>
> #include <iostream>
> #include <boost/exception/all.hpp>
>
> typedef boost::error_info<struct tag_my_info,int> my_info;
> struct my_error: virtual boost::exception, virtual std::exception { };
>
> void f() {
> BOOST_THROW_EXCEPTION(my_error() << my_info(42));
>
> // Uncomment the below (and comment the above) for the program to work
> //throw my_error() << my_info(42);
> }
>
> int main(int argc, char** argv) {
> try {
> f();
> }
> catch(my_error& x) {
> if(int const* mi = boost::get_error_info<my_info>(x)) {
> std::cout << "My info: " << *mi << std::endl;
> }
> }
>
> return 0;
> }
>
> Running the code with the BOOST_THROW_EXCEPTION macro:
>
> $ ./a.out
> Abort trap
>
> If as the comment says, I swap the code, all is well
>
> $ ./a.out
> My info: 42
>
> Below is the output from the g++ preprocessor for f()
>
> void f() {
> ::boost::exception_detail::throw_exception_(my_error() <<
> my_info(42),__PRETTY_FUNCTION__,"main.cpp",14);
> }
>
> Software versions are:
>
> $ g++ -v
> Using built-in specs.
> Target: x86_64-apple-darwin10
> Thread model: posix
> gcc version 4.4.6 (GCC)
>
> $ port list boost
> boost @1.47.0 devel/boost
>
> I'm on OSX SL using the tools provided by MacPorts. I've double checked
> the g++ search paths and there's only one copy of the boost hpp files
> and that's the ones that belong to the aforementioned boost package.
>
> I have no idea why the abort trap is being called. I admit I'm newish to
> C++.
>
> I've also asked this question on StackOverflow
> (http://stackoverflow.com/questions/8256874/boost-throw-exception-causing-abort-trap)
>
>
> Cheers,
>
>


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