[C++-sig] Re: crashes on functions with std::string arguments
David Abrahams
dave at boost-consulting.com
Tue Apr 5 14:11:54 CEST 2005
"Thomas Schipolowski" <thomas.schipolowski at tu-berlin.de> writes:
> Hello,
> I am using Python 2.3 and Boost_1_32_0 with VC6 on Windows 2000. I
> experience crashes due to heap corruption when a function or method with a
> std::string argument is called. The same problem is also triggered by the
> extract<std::string> facility.
> The following test code reproduces both conditions:
Not by itself, it doesn't! What Python code do you need to execute to
generate the crash?
> #include <string>
> #include <boost/python.hpp>
> using namespace boost::python;
>
> int test1(std::string s) {
> return s.end() - s.begin();
> }
>
> int test2(object o) {
> extract<std::string> extr(o);
> if (extr.check()) {
> std::string s(extr());
> return s.end() - s.begin();
> } else {
> return -1;
> }
> }
>
> BOOST_PYTHON_MODULE(test)
> {
> def("test1", test1);
> def("test2", test2);
> }
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list