From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23020 invoked by alias); 24 May 2012 14:23:01 -0000 Received: (qmail 22989 invoked by uid 22791); 24 May 2012 14:22:59 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 May 2012 14:22:45 +0000 From: "ndbecker2 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/53455] boost::python segfault Date: Thu, 24 May 2012 14:29:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ndbecker2 at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-05/txt/msg02385.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53455 Neal Becker changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ndbecker2 at gmail dot com --- Comment #6 from Neal Becker 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 >::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 >, QAMconstellation >::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 const&>::arg_rvalue_from_python(_object*) (arg_from_python.hpp:299) ==6162== by 0x11B81BEA: boost::python::arg_from_python 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_, boost::noncopyable > ("constellation_base", no_init) .def ("__call__", &apply_constellation) .def ("hard_decision", &apply_hard_decision) .add_property ("size", &constellation::size) .add_property ("gain", &constellation::gain) ; class_ , bases > > ("QAMconstellation", no_init) .def ("__init__", make_constructor (qam_from_object)) .add_property ("map", &get_map) .def_pickle(const_pickle_suite()) ; ...