[C++-sig] object.slice() infinite recursion bug

Jonathan Brandmeyer jbrandmeyer at earthlink.net
Sun Jan 4 06:04:40 CET 2004


This simple test demonstrates a bug in Boost.Python that results in
infinite recursion (and a subsequent crash) whenever you make a slice
using slice_nil for the upper and lower bounds.

I originally discovered it with the array class, but it also exists in
the object class, so that is what I'm putting up here.

This crash is exhibited with 1.30 and CVS HEAD using both Python 2.2 and
Python 2.3 with GCC 3.3.2.

-Jonathan Brandmeyer


------------------------------------recurse.cpp------
#include <boost/python.hpp>

void
test_slice_recursion( boost::python::object arr)
{
    // Haven't really found the right combination of using declarations
    // to use _ directly, yet.
    using namespace boost::python;
    arr.slice(_,_) = 2.0;
}

BOOST_PYTHON_MODULE(recurse)
{
	using boost::python::def;
	def( "recurse", &test_slice_recursion);
}

--------------------------------------recurse.py---
from recurse import recurse
# Should throw an exception for a list, but I get
# "segmentation fault"
recurse( [1, 2, 3])







More information about the Cplusplus-sig mailing list