Boost C++ Libraries: Ticket #184: raw_function with no keywords calls Py_INCREF on NULL https://svn.boost.org/trac10/ticket/184 <pre class="wiki">In the 1.30.0 release, as well as in the latest CVS, the following code (using the very example presented in the documentation for raw_function.hpp) results in a segfault: C++: #include &lt;boost/python/def.hpp&gt; #include &lt;boost/python/tuple.hpp&gt; #include &lt;boost/python/dict.hpp&gt; #include &lt;boost/python/module.hpp&gt; #include &lt;boost/python/raw_function.hpp&gt; using namespace boost::python; tuple raw(tuple args, dict kw) { return make_tuple(args, kw); } BOOST_PYTHON_MODULE(raw_test) { def("raw", raw_function(raw)); } Python: &gt;&gt;&gt; from raw_test import * &gt;&gt;&gt; def pyraw(*args, **kw): ... return (args, kw) ... &gt;&gt;&gt; pyraw(3, 4, foo = 'bar', baz = 42) ((3, 4), {'foo': 'bar', 'baz': 42}) &gt;&gt;&gt; raw(3, 4, foo = 'bar', baz = 42) ((3, 4), {'foo': 'bar', 'baz': 42}) &gt;&gt;&gt; pyraw(3,4) ((3, 4), {}) &gt;&gt;&gt; raw(3, 4) Segmentation fault The problem is that the "keywords" parameter passed to boost::python::detail::raw_dispatcher's operator() is NULL. This NULL pointer then gets wrapped in a borrowed_reference and passed to dict's constructor, which proceeds to make an attempt to Py_INCREF it. do_call() from Python/eval.c passes a NULL pointer for the keyword dictionary in Python releases 2.2.2, 2.2.3, and 2.3b2. I can't vouch for earlier releases. Note that the Python version of this function (pyraw, defined above) receives an empty dict for its keywords when no keywords are passed, and I would expect the Boost Python Library to give me the same. </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/184 Trac 1.4.3 david_abrahams Wed, 30 Jul 2003 11:36:21 GMT status changed https://svn.boost.org/trac10/ticket/184#comment:1 https://svn.boost.org/trac10/ticket/184#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> </ul> <pre class="wiki">Logged In: YES user_id=52572 Fixed now in CVS. Thanks for the excellent bug report. I'm backporting the fix to 1.30.1 </pre> Ticket