gc assertion failure

T

Todd Miller

Hi,

I recently discovered an assertion failure in the Python garbage
collection system when scripts using our C extension (numarray) exit.
The assertion is activated for Pythons configured using --with-pydebug.
I have a feeling I may be doing something wrong with garbage
collection support for some of our c types, but I'm not sure exactly
what.

Here is the assertion output:

python: Modules/gcmodule.c:231: visit_decref: Assertion `gc->gc.gc_refs
!= 0' failed.
Abort (core dumped)


Here's the traceback from gdb:

#0 0x4017dfd1 in kill () from /lib/libc.so.6
#1 0x4002d762 in raise () from /lib/libpthread.so.0
#2 0x4017dca2 in raise () from /lib/libc.so.6
#3 0x4017f04d in abort () from /lib/libc.so.6
#4 0x40177695 in __assert_fail () from /lib/libc.so.6
#5 0x080e9222 in visit_decref (op=0x405adc74, data=0x0) at
Modules/gcmodule.c:231
#6 0x0808cebf in tupletraverse (o=0x40a62f74, visit=0x80e9194
<visit_decref>, arg=0x0) at Objects/tupleobject.c:398
#7 0x080e9275 in subtract_refs (containers=0x813d2e8) at
Modules/gcmodule.c:250
#8 0x080e9a9e in collect (generation=2) at Modules/gcmodule.c:582
#9 0x080ea342 in PyGC_Collect () at Modules/gcmodule.c:993
#10 0x080e1bf6 in Py_Finalize () at Python/pythonrun.c:335
#11 0x08055543 in Py_Main (argc=4, argv=0xbffff6d4) at Modules/main.c:435
#12 0x08054cae in main (argc=4, argv=0xbffff6d4) at Modules/python.c:23
#13 0x4016c4ed in __libc_start_main () from /lib/libc.so.6

Can anyone give me any insight into what needs fixing?

Thanks,
Todd
 
M

Michael Hudson

Todd Miller said:
I recently discovered an assertion failure in the Python garbage
collection system when scripts using our C extension (numarray)
exit. The assertion is activated for Pythons configured using
--with-pydebug. I have a feeling I may be doing something wrong with
garbage collection support for some of our c types, but I'm not sure
exactly what.

Here is the assertion output:

python: Modules/gcmodule.c:231: visit_decref: Assertion
`gc->gc.gc_refs != 0' failed.
Abort (core dumped)


Here's the traceback from gdb:

[snip]
Can anyone give me any insight into what needs fixing?

Oh good grief, it could be anything (I think). Are you using the very
latest version of Python?

Cheers,
mwh
 
T

Todd Miller

Michael said:
I recently discovered an assertion failure in the Python garbage
collection system when scripts using our C extension (numarray)
exit. The assertion is activated for Pythons configured using
--with-pydebug. I have a feeling I may be doing something wrong with
garbage collection support for some of our c types, but I'm not sure
exactly what.

Here is the assertion output:

python: Modules/gcmodule.c:231: visit_decref: Assertion
`gc->gc.gc_refs != 0' failed.
Abort (core dumped)


Here's the traceback from gdb:


[snip]

Can anyone give me any insight into what needs fixing?


Oh good grief, it could be anything (I think).

Sorry...

I have two theories myself:

1) I need to implement explicit support for GC for some of the numarray
c types. I was hoping to avoid this by virtue of the unlikeliness of
reference cycles in the types in question.

2) There are other reference counting errors in numarray which are being
exposed during gc. In particular, it appears the tuple type is being
traversed when the assertion fails.
Are you using the very latest version of Python?

This was Python-2.3.2.
Cheers,
mwh

Thanks,
Todd
 
M

Michael Hudson

Todd Miller said:
Michael said:
Todd Miller said:
I recently discovered an assertion failure in the Python garbage
collection system when scripts using our C extension (numarray)
exit. The assertion is activated for Pythons configured using
--with-pydebug. I have a feeling I may be doing something wrong with
garbage collection support for some of our c types, but I'm not sure
exactly what.

Here is the assertion output:

python: Modules/gcmodule.c:231: visit_decref: Assertion
`gc->gc.gc_refs != 0' failed.
Abort (core dumped)


Here's the traceback from gdb: [snip]
Can anyone give me any insight into what needs fixing?
Oh good grief, it could be anything (I think).

Sorry...

It seems I was a bit extreme, reading followups. But I think that
assertion failure has been a symptom of some scary bugs in Python
itself.
I have two theories myself:

1) I need to implement explicit support for GC for some of the
numarray c types. I was hoping to avoid this by virtue of the
unlikeliness of reference cycles in the types in question.

2) There are other reference counting errors in numarray which are
being exposed during gc. In particular, it appears the tuple type
is being traversed when the assertion fails.

I know you found your error, but yet another tool for finding things
like this is the TrackRefs class from Zope's test runner. I found a
bunch of refcounting bugs in Python 2.3(.0) with it a couple months
back.

Cheers,
mwh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top