Boost logo

Boost :

From: SourceForge.net (noreply_at_[hidden])
Date: 2003-07-29 20:18:17


Bugs item #779964, was opened at 2003-07-29 18:18
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=779964&group_id=7586

Category: Python
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Conan Brink (conanbrink)
Assigned to: David Abrahams (david_abrahams)
Summary: raw_function with no keywords calls Py_INCREF on NULL

Initial Comment:
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 <boost/python/def.hpp>
#include <boost/python/tuple.hpp>
#include <boost/python/dict.hpp>
#include <boost/python/module.hpp>
#include <boost/python/raw_function.hpp>

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:
>>> from raw_test import *
>>> def pyraw(*args, **kw):
... return (args, kw)
...
>>> pyraw(3, 4, foo = 'bar', baz = 42)
((3, 4), {'foo': 'bar', 'baz': 42})
>>> raw(3, 4, foo = 'bar', baz = 42)
((3, 4), {'foo': 'bar', 'baz': 42})
>>> pyraw(3,4)
((3, 4), {})
>>> 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.

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=779964&group_id=7586

-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Boost-bugs mailing list
Boost-bugs_at_[hidden]
https://lists.sourceforge.net/lists/listinfo/boost-bugs


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk