[egenix-users] mx base 2.1.0b5 ref count bug?
M.-A. Lemburg
mal at egenix.com
Wed Apr 27 11:33:27 CEST 2005
David Rushby wrote:
> I'm using a heavy-debug build of Python 2.4.1 on i386 Linux. The
> Python interpreter was configured with a command similar to:
> OPT="-DPy_DEBUG -DCOUNT_ALLOCS" ./configure --prefix=...
> --without-pymalloc
>
> mx base 2.0.6, built with this Python interpreter, segfaulted when I
> tried to use it; I didn't try to pursue that issue.
This is a known bug in 2.0 and fixed in 2.1.0b5. We don't use
Python debug builds and the problem only appears in those special
Python builds - not in the regular ones.
> mx base 2.1.0b5 works fairly well, but causes the Python interpreter to
> fail a reference counting integrity check and abort when bogus
> arguments are passed to mx.DateTime.DateTime. Example:
> ------------------------------------------------------------
> py24d -c "import mx.DateTime as dt; dt.DateTime(-1, 13, 32)"
> Fatal Python error: UNREF invalid object
> Aborted
> ------------------------------------------------------------
> I have no familiarity with the mx code base, but from looking at
> mx/DateTime/mxDateTime/mxDateTime.c, the problem appears to be that
> function 'mxDateTime_Free' is registered as the destructor for type
> 'mxDateTime_Type', but 'mxDateTime_Free' is called explicitly by
> 'mxDateTime_Deallocate', which is called by
> 'mxDateTime_FromDateAndTime' in case of error, and 'mxDateTime_Free' is
> then called again by the Python garbage collector (even though the
> object in question has already been subjected to 'PyObject_Del()' by
> the previous execution of 'mxDateTime_Free').
>
> In other words:
> ------------------------------------------------------------
> mxDateTime_FromDateAndTime(erroneous args)
> -> mxDateTime_Deallocate(datetime)
> -> mxDateTime_Free(datetime)
> -> PyObject_Del(datetime)
> ...
> [Python garbage collector]
> -> mxDateTime_Free(datetime)
> -> PyObject_Del(datetime) /* aborts */
> ------------------------------------------------------------
>
> Perhaps 'mxDateTime_FromDateAndTime' should call 'Py_DECREF(datetime)'
> instead of 'mxDateTime_Deallocate' in the 'onError' handler, or
> 'mxDateTime_Deallocate' should call 'Py_DECREF(datetime)' instead of 'mxDateTime_Free(datetime)'?
Nice analysis.
Are you using the standard mxDateTime build or one
with WANT_SUBCLASSABLE_TYPES defined (mxDateTime_Deallocate
is only used by the latter) ?
In any case, please try our latest snapshot:
http://www.egenix.com/files/python/egenix-mx-base-2.1.0-2005-04-15.zip
to see if that makes any difference.
Thanks,
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Apr 27 2005)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
More information about the egenix-users
mailing list