Boost logo

Boost Users :

Subject: [Boost-users] [proto, fusion] Segfault in for_each
From: David A. Greene (greened_at_[hidden])
Date: 2010-05-10 20:53:01


I'm using boost 1.42. As part of a proto transform, I am flattening an
expression tree of comma operators and sending it to fusion::transform
followed by fusion::for_each, something like this:

for_each(transform(flatten(expr), func1), func2)

I am getting a segmentation fault in for_each. func1 does not appear
to be invoked. Program output:

Building type list:
comma(
    comma(
        function(
            terminal(int_)
          , terminal(32)
        )
      , function(
            terminal(float_)
          , terminal(32)
        )
    )
  , function(
        terminal(int_)
      , terminal(16)
    )
)
3 items

Program received signal SIGSEGV, Segmentation fault.
0x0804d52d in
boost::proto::result_of::child_c<Builder::Wrapper<boost::proto::exprns_::expr<boost::proto::tag::comma,
boost::proto::argsns_::list2<Builder::Wrapper<boost::proto::exprns_::expr<boost::proto::tag::function,
boost::proto::argsns_::list2<Builder::Wrapper<boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<Builder::keyword::int_>, 0l> > const&,
Builder::Wrapper<boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<int const&>, 0l> > >, 2l> > const&,
Builder::Wrapper<boost::proto::exprns_::expr<boost::proto::tag::function,
boost::proto::argsns_::list2<Builder::Wrapper<boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<Builder::keyword::float_>, 0l> > const&,
Builder::Wrapper<boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<int const&>, 0l> > >, 2l> > const&>, 2l> > const&,
0l>::call (e=...) at /usr/include/boost/proto/traits.hpp:1544

(gdb) print e
$1 = (const
Builder::Wrapper<boost::proto::exprns_::expr<boost::proto::tag::comma,
boost::proto::argsns_::list2<Builder::Wrapper<boost::proto::exprns_::expr<boost::proto::tag::function,
boost::proto::argsns_::list2<Builder::Wrapper<boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<Builder::keyword::int_>, 0l> > const&,
Builder::Wrapper<boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<int const&>, 0l> > >, 2l> > const&,
Builder::Wrapper<boost::proto::exprns_::expr<boost::proto::tag::function,
boost::proto::argsns_::list2<Builder::Wrapper<boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<Builder::keyword::float_>, 0l> > const&,
Builder::Wrapper<boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<int const&>, 0l> > >, 2l> > const&>, 2l> > &)
@0x0: <error reading variable>

Note the null expression reference.

fusion::distance on a begin/end pair from the same sequence works as expected
so I believe the sequence is at least well-formed.

I've been wrestling with this for days. Any ideas on how to debug this?

Thanks!

                                     -Dave


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