[Patches] [Patch #101362] fix GC debugging output w.r.t. exceptions

noreply@sourceforge.net noreply@sourceforge.net
Thu, 31 Aug 2000 08:07:48 -0700


Patch #101362 has been updated. 

Project: 
Category: core (C code)
Status: Accepted
Summary: fix GC debugging output w.r.t. exceptions

Follow-Ups:

Date: 2000-Aug-30 14:12
By: marangoz

Comment:
Related to SF patch 101346.

Use PySys_WriteStderr for debugging output to avoid interference with
exception handling. Remove offending PyErr_Clear. If not initialized,
output debugging messages through fprintf(stderr, ...) -- otherwise we can
start finalization with remaining gc.debug flags which may screw up
PySys_WriteStderr.
-------------------------------------------------------

Date: 2000-Aug-30 19:28
By: jhylton

Comment:
Two issues; one simple.

I don't understand why the Py_IsInitialized call is necessary.  Can you add a brief comment that explains it?

We discussed various patch options at a meeting today.  One of our goals was to eliminate all the sprintf calls in gcmodule.c, since PySys_WriteStderr has a printf-like interface.  Can you modify the local write_stderr so that it has the same interface? 
-------------------------------------------------------

Date: 2000-Aug-31 06:17
By: marangoz

Comment:
Ok -- removed sprintf calls & write_stderr altogether.
Use only PySys_WriteStderr.

The Py_IsInitialized business: you're right that it isn't necessary in the
current state of the collector. Nevertheless, PySys_WriteStderr() keeps the
collector dependent on an initialized interpreter for debugging output.
As long as the collector works only on Python objects and triggers
the collection process only on object allocations, this seems to be fine.

If someday the collector is made to be triggered on object deallocations
and it happens that a user GC'd object is freed (or allocated) after the
interpreter is finalized, we'll fail with a fatal error while there's no such
error and this is what I've tried to avoid (I have been bitten by this with
memprof, but the latter is lower lever).

The point is that once the gc.debug flags are set, there's no way to
deactivate them from C & there's no a gc_fini function, so the collector
will persist to output debugging traces independently on the Python state,
through a Python function. This is not very cool for a garbage collector,
which, in theory, is supposed to be at a lower level than the one of the
application code. So there -- we may be bitten by this in the future.
-------------------------------------------------------

Date: 2000-Aug-31 08:07
By: jhylton

Comment:
I'll check it in now, with two trivial changes (add .100 qualifier to two %s formats)

-------------------------------------------------------

-------------------------------------------------------
For more info, visit:

http://sourceforge.net/patch/?func=detailpatch&patch_id=101362&group_id=5470