meliae hits type_traverse assertion when dumping ctypes objects under Py_DEBUG
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Meliae |
Incomplete
|
Undecided
|
Unassigned |
Bug Description
This is probably a fairly obscure bug, but it's worth posting about in case it can be fixed (or the information is useful to someone else).
In several versions of Python, type_traverse in Objects/
assert(
meliae developers know about it, so they made a check in _scanner_core.c which tries to avoid tickling this assertion:
if (Py_TYPE(
|| (Py_TYPE(
&& !PyType_
{
/* Obviously we don't traverse if there is no traverse function. But
* also, if this is a 'Type' (class definition), then
* PyTypeObject.
* a HEAPTYPE. In debug builds, this can trip and cause failures, even
* though it doesn't seem to hurt anything.
* See: https:/
*/
do_traverse = 0;
}
This isn't a complete solution because type_traverse can be called indirectly from some custom tp_traverse. In fact, this is precisely what ctypes.
static int
CDataType_
{
StgDictObject *dict = PyType_
if (dict)
return PyType_
}
/*...*/
(traversepr
(inquiry)
To trigger this bug requires the following steps:
1) Build Python 3.2 using Py_DEBUG
2) Build meliae against this Python
3) Run the following script:
import ctypes
import sys
import meliae.scanner
meliae.
Here's what I get from running that:
Python 3.2.1 (default, Nov 20 2011, 14:49:05)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
[60256 refs]
>>> import sys
[60258 refs]
>>> import meliae.scanner
[61527 refs]
>>> meliae.
Assertion failed: (type->tp_flags & Py_TPFLAGS_
Abort trap
If you don't import ctypes, the dump succeeds without incident.
Workaround:
I just compiled typeobject.c with
if(
return -1;
instead of the assert.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 11/22/2011 7:22 AM, Robert Xiao wrote:
> Public bug reported:
>
> This is probably a fairly obscure bug, but it's worth posting about
> in case it can be fixed (or the information is useful to someone
> else).
>
I agree this affects meliae, but what can we actually do about it?
John
=:->
status: incomplete
-----BEGIN PGP SIGNATURE----- enigmail. mozdev. org/
WBwQACgkQJdeBCY SNAAMVrgCeLWTAw MoEyrMiao0Fb4PR Aryu YCUree6iMW61Gej R+
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://
iEYEARECAAYFAk7
ZL4AoKH7v4i8rba
=Xpfr
-----END PGP SIGNATURE-----