[C++-sig] V1 trouble with gcc 2.95.3

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Sat Apr 13 05:03:36 CEST 2002


> I am seeing the same problem on Cygwin.
> Not sure yet what the cause might be... hmm, it appears to be an
> uncaught exception. Can you set a breakpoint in __throw()? I'm not sure
> that I'm set up to debug this one here at the moment...

I didn't get anywhere with gdb.

> Please let me know if you find any clues.

I resorted to my "CheckPoint" debugging technique:

1. Insert the CheckPoint define as shown below.

2. Insert two Checkpoints in simple_vector.h:

    vector_double_wrapper(PyObject* self)
      : std::vector<double>() {
CheckPoint;
      }

    vector_double_wrapper(PyObject* self, int n)
      : std::vector<double>(n) {
CheckPoint;
    }

Result:

>>> import simple_vector
>>> v=simple_vector.vector_double()
simple_vector.cpp(22)
>>> v=simple_vector.vector_double(5)
Abort

3. Comment out the binding for the default constructor:

    //vector_double.def(python::constructor<>());

Result:

>>> import simple_vector
>>> v=simple_vector.vector_double(5)
simple_vector.cpp(27)

This seems to be very similar to the problem that I reported six weeks
ago. Only simpler because this time the cross_module.hpp header file is
not involved. The old message is attached.

Ralf


Date: Fri, 1 Mar 2002 17:22:28 -0800 (PST)
From: "Ralf W. Grosse-Kunstleve" <rwgk at cci.lbl.gov>
To: david.abrahams at rcn.com
Subject: BPL V1 problem: overload resolution & cross-module

Hi David,

Using the latest boost CVS snapshot and a static V1 libboost_python.a,
I am experiencing problems with overloaded functions such as:

    this_module.def(show_complex, "show");
    this_module.def(show_real, "show");

with:

  typedef std::vector<double> shared_real_array;
  typedef std::vector<std::complex<double> > shared_complex_array;

  void show_complex(shared_complex_array a);
  void show_real(shared_real_array a);

In Python:

from cctbx.arraytbx import std_vector ### similar to example/simple_vector.cpp
import debug2 ### the source code is attached
vd = std_vector.double(2)
debug2.show(vd)

This script works on the Alpha and on Windows (both VC60 and Codewarrior),
but crashes while executing the last line when using Linux/gcc-3.0.4
or SGI/CC (it crashes before getting to the first "CheckPoint").

It works everywhere if the .defs are swapped:

    this_module.def(show_real, "show");
    this_module.def(show_complex, "show");

There also is no problem if the "show" .defs are moved to the module
that exports the std_vector bindings.

I am guessing that there is a problem with the combination of
overload resolution and the use of the cross-module facilities.
This used to work in the past. I still have a Linux/gcc test-output
from January 8. I first discovered the problem with a cvs snapshot
from February 14. Would you have any clues that could help to
fix my problem?

Thanks,
        Ralf


#include <boost/python/cross_module.hpp>
#include <vector>

#include <iostream>
#define CheckPoint std::cout << __FILE__ << "(" << __LINE__ << ")" << std::endl
<< std::flush

namespace {

  typedef std::vector<double> shared_real_array;
  typedef std::vector<std::complex<double> > shared_complex_array;

  void show_complex(shared_complex_array a) {
CheckPoint;
    std::cout << a.size() << std::endl;
CheckPoint;
  }

  void show_real(shared_real_array a) {
CheckPoint;
    std::cout << a.size() << std::endl;
CheckPoint;
  }

#   include <cctbx/basic/from_bpl_import.h>

  void init_module(python::module_builder& this_module)
  {
    const std::string Revision = "$Revision: 1.14 $";
    this_module.add(ref(to_python(
        Revision.substr(11, Revision.size() - 11 - 2))), "__version__");

    python::import_converters<std::vector<double> >
    py_shared_double(
      "cctbx.arraytbx.std_vector", "double");

    python::import_converters<std::vector<std::complex<double> > >
    py_shared_complex_double(
      "cctbx.arraytbx.std_vector", "complex_double");

    this_module.def(show_complex, "show");
    this_module.def(show_real, "show");
  }

}

BOOST_PYTHON_MODULE_INIT(debug2)
{
  boost::python::module_builder this_module("debug2");
  init_module(this_module);
}


__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/





More information about the Cplusplus-sig mailing list