Christian Heimes added the comment:

I've added some debugging code to _Py_ForgetReference and now I'm
getting this:

$ ./reinit_test
round 1
[23832 refs]
round 2
[24558 refs]
round 3
* ob
object  : <refcnt 0 at 0x821d728>
type    : str
refcount: 0
address : 0x821d728
* op->_ob_prev->_ob_next
object  : <refcnt 0 at 0x821d728>
type    : str
refcount: 0
address : 0x821d728
* op->_ob_next->_ob_prev
object  : buffer(b'')
type    : buffer
refcount: 1
address : 0x826c8c8
* refchain
object  : <refcnt 0 at 0x81a1500>
type    : NULL
refcount: 0
address : 0x81a1500
Fatal Python error: UNREF invalid object
Aborted

Added file: http://bugs.python.org/file8791/py3k_reinit2.patch

__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1306>
__________________________________
Index: Python/pythonrun.c
===================================================================
--- Python/pythonrun.c	(Revision 59091)
+++ Python/pythonrun.c	(Arbeitskopie)
@@ -502,6 +502,12 @@
 	/* Cleanup Unicode implementation */
 	_PyUnicode_Fini();
 
+	/* reset file system default encoding */
+	if (!Py_HasFileSystemDefaultEncoding) {
+		free(Py_FileSystemDefaultEncoding);
+        	Py_FileSystemDefaultEncoding = NULL;
+	}
+
 	/* XXX Still allocated:
 	   - various static ad-hoc pointers to interned strings
 	   - int and float free list blocks
Index: Python/bltinmodule.c
===================================================================
--- Python/bltinmodule.c	(Revision 59091)
+++ Python/bltinmodule.c	(Arbeitskopie)
@@ -16,10 +16,13 @@
 */
 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
 const char *Py_FileSystemDefaultEncoding = "mbcs";
+const int Py_HasFileSystemDefaultEncoding = 1;
 #elif defined(__APPLE__)
 const char *Py_FileSystemDefaultEncoding = "utf-8";
+const int Py_HasFileSystemDefaultEncoding = 1;
 #else
 const char *Py_FileSystemDefaultEncoding = NULL; /* use default */
+const int Py_HasFileSystemDefaultEncoding = 0;
 #endif
 
 static PyObject *
Index: Include/fileobject.h
===================================================================
--- Include/fileobject.h	(Revision 59091)
+++ Include/fileobject.h	(Arbeitskopie)
@@ -20,6 +20,7 @@
    If non-NULL, this is different than the default encoding for strings
 */
 PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding;
+PyAPI_DATA(const int) Py_HasFileSystemDefaultEncoding;
 
 /* Internal API
 
Index: Objects/object.c
===================================================================
--- Objects/object.c	(Revision 59091)
+++ Objects/object.c	(Arbeitskopie)
@@ -1532,8 +1532,15 @@
 	if (op->ob_refcnt < 0)
 		Py_FatalError("UNREF negative refcnt");
 	if (op == &refchain ||
-	    op->_ob_prev->_ob_next != op || op->_ob_next->_ob_prev != op)
+	    op->_ob_prev->_ob_next != op || op->_ob_next->_ob_prev != op) {
+		fprintf(stderr, "* ob\n");
+		_PyObject_Dump(op);
+		fprintf(stderr, "* op->_ob_prev->_ob_next\n");
+		_PyObject_Dump(op->_ob_prev->_ob_next);
+		fprintf(stderr, "* op->_ob_next->_ob_prev\n");
+		_PyObject_Dump(op->_ob_next->_ob_prev);
 		Py_FatalError("UNREF invalid object");
+	}
 #ifdef SLOW_UNREF_CHECK
 	for (p = refchain._ob_next; p != &refchain; p = p->_ob_next) {
 		if (p == op)
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to