[C++-sig] V2: another run time error

David Abrahams david.abrahams at rcn.com
Fri Apr 12 22:54:58 CEST 2002


Peter,

The crash is a bug in the intel compiler's EH implementation. It should
report an error (with, at this stage, a cryptic error message --
TypeError: bad argument type for built-in operation). The problem is
that you're requesting that the result of an rvalue conversion (Python
complex -> C++ complex) be bound to a non-const reference. If you change
your intialization to:

  m
    .add(class_<M>("M")
         .def_init(args<std::complex<double> const&>()))
    ;

the code will work.

----- Original Message -----
From: "Peter Bienstman" <Peter.Bienstman at rug.ac.be>
To: <c++-sig at python.org>
Sent: Friday, April 12, 2002 2:52 PM
Subject: [C++-sig] V2: another run time error


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This one is for the record. It's a run time error using Intel V6 under
Linux.
This platform/compiler combo is less important to me, because gcc works
fine
there, so I'm not losing any sleep over this. It could also very well be
Intel's fault ;-)

Peter

#define BOOST_PYTHON_DYNAMIC_LIB
#define BOOST_PYTHON_V2

#include <boost/python/module.hpp>
#include <boost/python/class.hpp>
#include <boost/mpl/type_list.hpp>

#include <complex>

struct M {M(const std::complex<double>&) {} };

BOOST_PYTHON_MODULE_INIT(m)
{
  using namespace boost::python;
  using boost::mpl::type_list;

  module m("m");

  m
    .add(class_<M>("M")
         .def_init(type_list<std::complex<double>&>()))
    ;

}

pbienst at hunsmac:~/tmp$ more crash.py
from m import *
M(1j)

Stacktrace

#0  0x4001cab1 in
boost::python::converter::reference_from_python<std::complex<double>&>::
reference_from_python(_object*)
() from ./m.so
#1  0x4001d843 in
boost::python::from_python<std::complex<double>&>::from_python(_object*)
()
from ./m.so
#2  0x4001e15d in _object*
boost::python::detail::returning<void>::call<boost::python::default_call
_policies,
_object*, std::complex<double>&>(void (*)(_object*,
std::complex<double>&),
_object*, _object*, boost::python::default_call_policies const*) () from
./m.so
#3  0x4001dc99 in
boost::detail::function::function_obj_invoker2<boost::_bi::bind_t<_objec
t*,
boost::python::detail::caller, boost::_bi::list4<boost::_bi::value<void
(*)(_object*, std::complex<double>&)>, boost::arg<1>, boost::arg<2>,
boost::_bi::value<boost::python::default_call_policies> > >, _object*,
_object*, _object*>::invoke(boost::detail::function::any_pointer,
_object*,
_object*) () from ./m.so
#4  0x404b353e in operator() (this=0x81a67b8, a0=0x81a65cc, a1=0x0)
    at function_template.hpp:302
#5  0x40491e29 in call (this=0x81a67b0, args=0x81a65cc, keywords=0x0)
    at src/object/function.cpp:42
#6  0x404b36f2 in operator() (this=0xbffff308) at
src/object/function.cpp:129
#7  0x404b3185 in invoke (function_obj_ptr=
      {obj_ptr = 0xbffff308, const_obj_ptr = 0xbffff308, func_ptr =
0xbffff308})
    at function_template.hpp:128
#8  0x404cf3d7 in operator() (this=0xbffff2c4) at
function_template.hpp:300
#9  0x40493493 in boost::python::handle_exception_impl (f=0xbffff2c4)
    at src/errors.cpp:20
#10 0x404b37e5 in boost::python::handle_exception (f=
      {m_result = @0xbffff318, m_f = 0x81a67b0, m_args = 0x81a65cc,
m_keywords
= 0x0})
    at errors.hpp:28
#11 0x40492398 in boost::python::objects::function_call (func=0x81a67b0,
args=0x81a65cc,
    kw=0x0) at src/object/function.cpp:161
#12 0x080e82a2 in PyObject_Call (func=0x81a67b0, arg=0x81a65cc, kw=0x0)
    at Objects/abstract.c:1665
#13 0x080f0117 in instancemethod_call (func=0x81a67b0, arg=0x81a5e4c,
kw=0x0)
    at Objects/classobject.c:2276
#14 0x080e82a2 in PyObject_Call (func=0x81934e4, arg=0x81a5e4c, kw=0x0)
    at Objects/abstract.c:1665
#15 0x0806c734 in slot_tp_init (self=0x81a6804, args=0x81a5e4c,
kwds=0x0)
    at Objects/typeobject.c:3344
#16 0x0806a801 in type_call (type=0x81ce02c, args=0x81a5e4c, kwds=0x0)
    at Objects/typeobject.c:159
#17 0x080e82a2 in PyObject_Call (func=0x81ce02c, arg=0x81a5e4c, kw=0x0)
    at Objects/abstract.c:1665
#18 0x0808152d in do_call (func=0x81ce02c, pp_stack=0xbffff534, na=1,
nk=0)
    at Python/ceval.c:3251
#19 0x0807e034 in eval_frame (f=0x819bed4) at Python/ceval.c:2016
#20 0x0807ed5c in PyEval_EvalCodeEx (co=0x81aacb8, globals=0x8194ed4,
locals=0x8194ed4,
    args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0,
closure=0x0)
    at Python/ceval.c:2574
#21 0x08081425 in PyEval_EvalCode (co=0x81aacb8, globals=0x8194ed4,
locals=0x8194ed4)
    at Python/ceval.c:483
#22 0x0809e44b in run_node (n=0x81aa4f0, filename=0xbffff8e3 "crash.py",
    globals=0x8194ed4, locals=0x8194ed4, flags=0xbffff6ac) at
Python/pythonrun.c:1083
#23 0x0809cb6f in PyRun_SimpleFileExFlags (fp=0x81852a8,
filename=0xbffff8e3
"crash.py",
    closeit=1, flags=0xbffff6ac) at Python/pythonrun.c:689
#24 0x08055d9a in Py_Main (argc=2, argv=0xbffff784) at
Modules/main.c:369
#25 0x08055849 in main (argc=2, argv=0xbffff784) at Modules/python.c:10
#26 0x402e75b0 in __libc_start_main () from /lib/libc.so.6
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8tzr64dgPAIjyquoRAgQKAKDKCyGRSbkESbIXz6WRr+wNDSzWxgCePmtG
N/T4NxcQM5d0WlHb7hefl7s=
=e6Qb
-----END PGP SIGNATURE-----



_______________________________________________
C++-sig mailing list
C++-sig at python.org
http://mail.python.org/mailman/listinfo/c++-sig







More information about the Cplusplus-sig mailing list