New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SSL tests leak memory #45810
Comments
I'm seeing leaks in the test_ssl run, after various socket.py changes. |
I don't see leaks when I run the tests with $ ./python Lib/test/regrtest.py -R:: test_ssl.py
test_ssl
beginning 9 repetitions
123456789
.........
1 test OK.
[80034 refs] |
What platform? Bill On Nov 20, 2007 11:21 PM, Christian Heimes <report@bugs.python.org> wrote:
|
Ubuntu Linux x86 |
Are you sure that the SSL tests are still leaking memory? The tests |
I'm seeing the leaks on my Leopard machine. I haven't had a chance to look On Dec 1, 2007 11:20 AM, Christian Heimes <report@bugs.python.org> wrote:
|
I can reproduce the problem when I run the ssl tests with -unetwork. I've used PYTHONDUMREFS and combinerefs.py to find the leaking objects. 0x9fd3e4c [1] SSLSocket in the output. I guess the problem is connected to:: _ssl.sslwrap(self, server_side,
keyfile, certfile,
cert_reqs, ssl_version, ca_certs) in Lib/ssl.py. I'm digging in |
I may have found the error. The PySSL_Type doesn't support GC but it I've started to fix it but I don't have time to work on the problem 'til Program received signal SIGSEGV, Segmentation fault. |
I found the problem! I've to use PyObject_GC_New instead of PyObject_New |
I get a segfault when I run it like this: $ ./python.exe Lib/test/regrtest.py -uall test_ssl
test_ssl
Segmentation fault
$ (Without -uall it passes.) |
New patch The new patch doesn't cause a seg fault but it doesn't help. It test_ssl leaked [1610, 1610] references, sum=3220 |
The new patch works and fixes the ref leak. I had to move the call |
I will look at this in an hour or so, after I bring Orlijn to school |
Guido van Rossum wrote:
I found two problems with the _real_close() call in PySSL_dealloc. I'm o = PyObject_CallMethod((PyObject*)self->Socket, "_real_close", ""); Christian |
Oops, I just committed revision 59394. |
I just reverted it. I put a bit of debugging in the call to |
I'm giving up on this for now. There are other weird bugs in the code, >>> x = urllib.urlopen("https://mail.google.com").read()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/google/home/guido/python/py3kd/Lib/io.py", line 463,
in read
return self.readall()
File "/usr/local/google/home/guido/python/py3kd/Lib/io.py", line 473,
in readall
data = self.read(DEFAULT_BUFFER_SIZE)
File "/usr/local/google/home/guido/python/py3kd/Lib/io.py", line 466,
in read
del b[n:]
TypeError: slice indices must be integers or None or have an __index__
method
[64813 refs]
>>> The debugger tells me that 'n' contains a bytes object instead of an |
Guido van Rossum wrote:
I agree! I've not enough time to work on the patch. A working patch Christian |
I'm still not sure what the problem is. This code was working fine when I I intend to wolf-fence the tests in the test module until I find a single On Dec 6, 2007 11:45 AM, Christian Heimes <report@bugs.python.org> wrote:
|
Don't worry, I did back it out before releasing 3.0a2. I believe I hacked your code a bit before checking it in (or after you Did you see my bug report with a TypeError? |
I think I've figured it out. My initial patch to socket.py and ssl.py Adding _real_close() back to the socket module fixes most of the leak, |
So, what's the final status of __del__ in py3K? The other bit of leak |
Is it possible that you have the same problem as in To be sure, check the gc.garbage variable at the end of the test. It may |
There are no current plans to change __del__ in Py3k. |
The other leak comes from this code: s = ssl.wrap_socket(socket.socket(), ...)
s.connect((SOME BOGUS ADDRESS OR SERVER)) The connect() fails, and the SSLSocket "s"gets dropped on the floor, Could this be because the base class is a C class? |
gc.garbage is always empty. |
I wonder if Christian Heimes was correct that the ssl object needs GC Alternatively, if 's' is involved in a cycle *and* any of the objects --Guido On Dec 10, 2007 3:30 PM, Bill Janssen <report@bugs.python.org> wrote:
|
Ah, I see what's going on. The revision of the socket code (nice job, The right fix is to make the ref in the SSL C code a weakref. |
Guido van Rossum wrote:
A combination of GC support and the removal of __del__ from SSLSocket The code contains a reference cycle. ssl.SSLSocket() contains a Christian |
I think Christian analysis is right, in that it takes a bit of GC
Now SSLSockets get cleaned up properly by the GC system. One question: _real_close() is what Java calls a "protected" method. Do |
Here's a patch -- take a look and let me know. I also added a real asyncore server test. |
Now, about the "confused signature" of SSLSocket.read(). I'm not sure how confused it is. It's sui generis; SSLSocket doesn't Anyway, the error is coming from a bug in the implementation of |
Hm, when I run the full test_ssl test suite with ./python Lib/test/regrtest.py -v -uall test_ssl it always hangs in testAsyncoreServer after printing this: testAsyncoreServer (test.test_ssl.ThreadedTests) ... |
It hangs on my Linux box, too. I've not yet tried on Windows. |
Good catch. I flipped a bit cleaning up the C code. Here's a fixed patch. |
Great! Go ahead and check it in. Sorry for deleting the _real_close() Enjoy your time away! |
I spoke too soon. In a debug build, this hangs forever during the ./python.exe Lib/test/regrtest.py -uall -R1:1 test_ssl Adding -v, it looks like two iterations are carried out perfectly (one testAsyncoreServer (test.test_ssl.ThreadedTests) ... |
The server isn't handling the close event properly. I'll fix that. On Dec 13, 2007 9:06 PM, Guido van Rossum <report@bugs.python.org> wrote:
|
Here's an update version where the asyncore test server properly handles |
Perfect! Check it in. |
Done. On Dec 14, 2007 9:44 AM, Guido van Rossum <report@bugs.python.org> wrote:
|
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: