Christian Heimes added the comment:

I may have found the error. The PySSL_Type doesn't support GC but it
should in order to clean up self->Socket. 

I've started to fix it but I don't have time to work on the problem 'til
tonight. The patch causes a seg fault. I may have overlooked or
misunderstood something.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1210324800 (LWP 31486)]
0x08127d03 in gc_list_remove (node=0x86d1cac) at Modules/gcmodule.c:158
158             node->gc.gc_prev->gc.gc_next = node->gc.gc_next;

Added file: http://bugs.python.org/file8884/ssl_gc.patch

__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1469>
__________________________________
Index: Tools/scripts/combinerefs.py
===================================================================
--- Tools/scripts/combinerefs.py	(Revision 59376)
+++ Tools/scripts/combinerefs.py	(Arbeitskopie)
@@ -86,7 +86,8 @@
             break
 
 def combine(fname):
-    f = file(fname)
+    f = open(fname)
+
     fi = iter(f)
 
     for line in read(fi, re.compile(r'^Remaining objects:$'), False):
Index: Modules/_ssl.c
===================================================================
--- Modules/_ssl.c	(Revision 59376)
+++ Modules/_ssl.c	(Arbeitskopie)
@@ -1050,16 +1050,32 @@
 	return NULL;
 }
 
-static void PySSL_dealloc(PySSLObject *self)
+/* GC support. */
+static int
+PySSL_traverse(PySSLObject *self, visitproc visit, void *arg)
 {
+	Py_VISIT(self->Socket);
+	return 0;
+}
+
+static int
+PySSL_clear(PySSLObject *self)
+{
+	Py_CLEAR(self->Socket);
+	return 0;
+}
+
+static void
+PySSL_dealloc(PySSLObject *self)
+{
+	PySSL_clear(self);
 	if (self->peer_cert)	/* Possible not to have one? */
 		X509_free (self->peer_cert);
 	if (self->ssl)
 		SSL_free(self->ssl);
 	if (self->ctx)
 		SSL_CTX_free(self->ctx);
-	Py_XDECREF(self->Socket);
-	PyObject_Del(self);
+	Py_Type(self)->tp_free((PyObject *)self);
 }
 
 /* If the socket has a timeout, do a select()/poll() on the socket.
@@ -1372,7 +1388,7 @@
 	/* methods */
 	(destructor)PySSL_dealloc,	/*tp_dealloc*/
 	0,				/*tp_print*/
-	(getattrfunc)PySSL_getattr,	/*tp_getattr*/
+	0,				/*tp_getattr*/
 	0,				/*tp_setattr*/
 	0,				/*tp_compare*/
 	0,				/*tp_repr*/
@@ -1380,6 +1396,32 @@
 	0,				/*tp_as_sequence*/
 	0,				/*tp_as_mapping*/
 	0,				/*tp_hash*/
+	0,				/* tp_call */
+	0,				/* tp_str */
+	PyObject_GenericGetAttr,	/* tp_getattro */
+	0,				/* tp_setattro */
+	0,				/* tp_as_buffer */
+	Py_TPFLAGS_DEFAULT | 
+		Py_TPFLAGS_HAVE_GC,	/* tp_flags */
+	0,				/* tp_doc */
+	(traverseproc)PySSL_traverse,	/* tp_traverse */
+	(inquiry)PySSL_clear,		/* tp_clear */
+	0,				/* tp_richcompare */
+	0,				/* tp_weaklistoffset */
+	0,				/* tp_iter */
+	0,				/* tp_iternext */
+	PySSLMethods,			/* tp_methods */
+	0,				/* tp_members */
+	0,				/* tp_getset */
+	0,				/* tp_base */
+	0,				/* tp_dict */
+	0,				/* tp_descr_get */
+	0,				/* tp_descr_set */
+	0,				/* tp_dictoffset */
+	0,				/* tp_init */
+	PyType_GenericAlloc,		/* tp_alloc */
+	PyType_GenericNew,		/* tp_new */
+	PyObject_GC_Del,		/* tp_free */
 };
 
 #ifdef HAVE_OPENSSL_RAND
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to