Jack Diederich wrote:

If you build metakit using a --with-python that ponits to a
debug build of python it will segfault.  I'm fairly certain this
is due to the HEAD struct being different than what is expected.
Specifically I think the _ob_next and _ob_prev members (which are
only in debug builds) are corrupted or not set.  ob_refcnt's
seem to be correct, the segfault comes when python is trying
to assert references during object teardown.

C++ classes that are also valid PyObject pointers are tricky,
the initialization has to be just right.  I don't personally
know enough to fix it.

Good catch, but I can't seem to find the reason either.


The logic in MK is as follows:

Python does "manual inheritance", by putting the same struct fields at the start in every object (see #define PyObject_HEAD in object.h). MK is C++, so at the time I decided to take advantage of that and define a PyHead *class* with exactly the same structure, and then have all other objects (PyProperty, PyRowRef, PyView) defined as C++ derived classes. It adds the ability to pass pointers to any of those objects in places where a PyObject* is expected without having to cast them.

This sounds more ominous than it is, really. All it took, was a minute header file called "metakit/python/PyHead.h" to make things work that way. In there is logic which initializes the two fields, and an #ifdef which initializes two more when this is a debug build. Looking at object.h, I can see no difference in declaration & initialization, for release nor debug builds.

Something must have changed, but I'm at a loss as to what that might be. MK used to work fine with debug builds.

If anyone can shed light on this, please tell...

-jcw

_____________________________________________
Metakit mailing list  -  [EMAIL PROTECTED]
http://www.equi4.com/mailman/listinfo/metakit

Reply via email to