[Bug c++/53455] boost::python segfault

ndbecker2 at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu May 24 14:29:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53455

Neal Becker <ndbecker2 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ndbecker2 at gmail dot com

--- Comment #6 from Neal Becker <ndbecker2 at gmail dot com> 2012-05-24 14:22:43 UTC ---
I believe I hit the same bug, using extract on a polymorphic type.

In the old code (which segfaults), I used make_constructor, passing object to
it, and using 
extract.

In the new code (which does not segfault), I don't use make_constructor, just
use bp::init.  My segfault 
is gone.  Maybe just luck?

valgrind python test_constellation.py 
==6162== Memcheck, a memory error detector
==6162== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==6162== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==6162== Command: python test_constellation.py
==6162== 
==6162== Invalid read of size 8
==6162==    at 0x11B79748:
boost::python::objects::polymorphic_id_generator<QAMconstellation<double>
>::execute(void*) (inheritance.hpp:43)
==6162==    by 0x13F585A3: boost::(anonymous namespace)::convert_type(void*,
boost::python::type_info, boost::python::type_info, bool) (in
/usr/local/src/boost_1_49_0.hg.nondarray/stage/lib/libboost_python.so.1.49.0)
==6162==    by 0x11B857D9:
boost::python::objects::pointer_holder<std::auto_ptr<QAMconstellation<double>
>, QAMconstellation<double> >::holds(boost::python::type_info, bool)
(pointer_holder.hpp:150)
==6162==    by 0x13F50006: boost::python::objects::find_instance_impl(_object*,
boost::python::type_info, bool) (in
/usr/local/src/boost_1_49_0.hg.nondarray/stage/lib/libboost_python.so.1.49.0)
==6162==    by 0x13F4B304:
boost::python::converter::rvalue_from_python_stage1(_object*,
boost::python::converter::registration const&) (in
/usr/local/src/boost_1_49_0.hg.nondarray/stage/lib/libboost_python.so.1.49.0)
==6162==    by 0x11B82F02:
boost::python::converter::arg_rvalue_from_python<constellation<double>
const&>::arg_rvalue_from_python(_object*) (arg_from_python.hpp:299)
==6162==    by 0x11B81BEA: boost::python::arg_from_python<constellation<double>
const&>::arg_from_python(_object*) (arg_from_python.hpp:70)
...

This particular code uses inheritance (I rarely use it).  It looks something
like:


BOOST_PYTHON_MODULE(constellation) {

  boost::numpy::initialize();

  class_<constellation<double>, boost::noncopyable > ("constellation_base",
no_init)
    .def ("__call__", &apply_constellation<double>)
    .def ("hard_decision", &apply_hard_decision<double>)
    .add_property ("size", &constellation<double>::size)
    .add_property ("gain", &constellation<double>::gain)
    ;

  class_<QAMconstellation<double> , bases<constellation<double> > >
("QAMconstellation", no_init)
    .def ("__init__", make_constructor (qam_from_object<double>))
    .add_property ("map", &get_map)
    .def_pickle(const_pickle_suite<double>())
    ;
...



More information about the Gcc-bugs mailing list