Re: [Boost-bugs] [Boost C++ Libraries] #8978: Segfault crash in boost.python with keyword arguments and overloads.

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8978: Segfault crash in boost.python with keyword arguments and overloads.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-08-08 18:32:28


#8978: Segfault crash in boost.python with keyword arguments and overloads.
-------------------------------+-------------------------
  Reporter: amohr@… | Owner: rwgk
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: Python
   Version: Boost 1.51.0 | Severity: Showstopper
Resolution: | Keywords:
-------------------------------+-------------------------

Comment (by amohr@…):

 Oh man, I didn't realize it would format my input. Here's the repro and
 patch again, hopefully better formatted.


 {{{
 // C++
 #include <boost/python.hpp>

 static void f1(int a0, int a1) { }
 static void f2(int a0, int a1, int a2) { }

 BOOST_PYTHON_MODULE(kwargCrash) {
     boost::python::def("f", f1, (arg("a1")=2));
     boost::python::def("f", f2, (arg("a2")=2));
 }

 # Python
 import kwargCrash
 kwargCrash.f(0, a1=2)


 --- ./libs/python/src/object/function.cpp.orig 2013-07-22
 17:38:54.000000000 -0700
 +++ ./libs/python/src/object/function.cpp 2013-08-07
 10:25:26.963988000 -0700
 @@ -182,6 +182,16 @@
                              // Get the keyword[, value pair]
 corresponding
                              PyObject* kv =
 PyTuple_GET_ITEM(f->m_arg_names.ptr(), arg_pos);

 + // If kv is None, this overload does not
 accept a
 + // keyword argument in this position, meaning
 that
 + // the caller did not supply enough
 positional
 + // arguments. Reject the overload.
 + if (kv == Py_None) {
 + PyErr_Clear();
 + inner_args = handle<>();
 + break;
 + }
 +
                              // If there were any keyword arguments,
                              // look up the one we need for this
                              // argument position


 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8978#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:13 UTC