-
-
Notifications
You must be signed in to change notification settings - Fork 32k
asyncio SSL contexts leak sockets after calling close with certain Apache servers #73592
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
Comments
with the attached code note how HttpClient.connection_lost callback is never called for the madis server. The madis server is an apache server, I tried with the OSX apache server and could not reproduce the issue so it seems something particular about their apache version or configuration. This is a pretty critical issue as close() does not release the socket. |
updating to make default the error case (madis) |
madis-data.ncep.noaa.gov side does not complete ssl shutdown process. |
Thanks so much for the patch! may want to change spelling of what was supposed to be "shutdown" =) Also think it's worth a comment stating why it's needed? Like certain Apache servers were noticed to not complete the SSL shutdown process. |
Can you guys create a PR on github.com/python/cpython? |
There are two PRs for this issue. Is one depending on the other? PR 409 has merge conflict that needs to be resolved. |
No, they all address slightly different bugs. All need to be merged though.
Yes, it seems that it's based on 3.6 branch. I asked the author to rebase it. |
While testing current 3.6 top of trunk, I noticed spurious error messages being reported that were not causing the tests to fail. Investigating further, I found the culprit to be this issue's 6e14fd2. Curiously, the errors aren't showing up on buildbots although I can reproduce 100% on both platforms I've tried: Debian Linux and macOS 10.12. For some reason that needs to be explored, using -W on regrtest causes the messages to be suppressed and the buildbots use -w by default. $ ./python
# without -w or -W
$ ./python -m test test_asyncio
Run tests sequentially
0:00:00 [1/1] test_asyncio
Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0xb55423b4>
transport: None
Traceback (most recent call last):
File "/py/3x/unix/source/Lib/asyncio/sslproto.py", line 660, in _process_write_backlog
self._transport.write(chunk)
AttributeError: 'NoneType' object has no attribute 'write'
Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0xb5542504>
transport: None
Traceback (most recent call last):
File "/py/3x/unix/source/Lib/asyncio/sslproto.py", line 660, in _process_write_backlog
self._transport.write(chunk)
AttributeError: 'NoneType' object has no attribute 'write'
Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0xb639f8bc>
transport: None
Traceback (most recent call last):
File "/py/3x/unix/source/Lib/asyncio/sslproto.py", line 660, in _process_write_backlog
self._transport.write(chunk)
AttributeError: 'NoneType' object has no attribute 'write'
Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0xb6126f84>
transport: None
Traceback (most recent call last):
File "/py/3x/unix/source/Lib/asyncio/sslproto.py", line 660, in _process_write_backlog
self._transport.write(chunk)
AttributeError: 'NoneType' object has no attribute 'write'
Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0xb6392fbc>
transport: None
Traceback (most recent call last):
File "/py/3x/unix/source/Lib/asyncio/sslproto.py", line 660, in _process_write_backlog
self._transport.write(chunk)
AttributeError: 'NoneType' object has no attribute 'write'
Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0xb671dedc>
transport: None
Traceback (most recent call last):
File "/py/3x/unix/source/Lib/asyncio/sslproto.py", line 660, in _process_write_backlog
self._transport.write(chunk)
AttributeError: 'NoneType' object has no attribute 'write'
1 test OK. Total duration: 13 sec # with -w
$ ./python -m test -w test_asyncio
Run tests sequentially
0:00:00 [1/1] test_asyncio
Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0xb4b15b5c>
transport: None
Traceback (most recent call last):
File "/py/3x/unix/source/Lib/asyncio/sslproto.py", line 660, in _process_write_backlog
self._transport.write(chunk)
AttributeError: 'NoneType' object has no attribute 'write'
Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0xb581f264>
transport: None
Traceback (most recent call last):
File "/py/3x/unix/source/Lib/asyncio/sslproto.py", line 660, in _process_write_backlog
self._transport.write(chunk)
AttributeError: 'NoneType' object has no attribute 'write'
Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0xb53f068c>
transport: None
Traceback (most recent call last):
File "/py/3x/unix/source/Lib/asyncio/sslproto.py", line 660, in _process_write_backlog
self._transport.write(chunk)
AttributeError: 'NoneType' object has no attribute 'write'
Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0xb65faf14>
transport: None
Traceback (most recent call last):
File "/py/3x/unix/source/Lib/asyncio/sslproto.py", line 660, in _process_write_backlog
self._transport.write(chunk)
AttributeError: 'NoneType' object has no attribute 'write'
Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0xb5816c04>
transport: None
Traceback (most recent call last):
File "/py/3x/unix/source/Lib/asyncio/sslproto.py", line 660, in _process_write_backlog
self._transport.write(chunk)
AttributeError: 'NoneType' object has no attribute 'write'
Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0xb582dea4>
transport: None
Traceback (most recent call last):
File "/py/3x/unix/source/Lib/asyncio/sslproto.py", line 660, in _process_write_backlog
self._transport.write(chunk)
AttributeError: 'NoneType' object has no attribute 'write'
1 test OK. Total duration: 13 sec # with -W -> no messages Total duration: 13 sec |
Er, "For some reason that needs to be explored, using -W on regrtest causes the messages to be suppressed and the buildbots use -w by default." That should be "use -W by default". |
FTR, same behavior with master (3.7) top of trunk. |
Nikolay, can you please take a look? |
yes, i am on it |
Nick, have you been able to find what the problem is? If not, we'll need to pull this change out of 3.6.2. |
It's interesting to see how |
OTOH we weren't setting the transport to None before, we were just closing it. Is setting it to None really necessary? |
Alright, let's play it safe. I'm going to be reverting the change from all branches. Nick, if you are able to figure this out please create a new PR. |
See also bpo-29970. |
This is not problem with madis-data.ncep.noaa.gov not doing ssl shutdown, this is problem with asyncio not doing it. Patch from this bpo-30698 issue fix this too. |
Let’s close this issue then. I don’t like it anyway.
|
Yury, based on the most recent comments, can this issue be closed now? |
Not sure, I'm reviewing the patch for bpo-30698, let's see if it fixes the problem. |
This is marked as Critical so either we should change the priority or fix it soon :) |
I'm picking up the issue. |
I'm skeptical about The bugfix could be backported to Python 3.6 but I very not sure about the need for 3.5. Yury Selivanov please confirm. |
The attached script looks very innocent, and it's worrisome that it's that easy to make an asyncio SSL server to leak sockets in some contexts. I think it's OK to fix 3.5, but let's make the final decision when we have an approved PR. I merged Nick's PR once, but then it introduced some problems on buildbots (https://bugs.python.org/msg295659), so I reverted the commit. I'd suggest to look at the attached script again (scratch_1.py) and try to understand what exactly causes the problem with that specific Apache server version. I'd also suggest to come up with a *functional* unittest that reproduces it (you can grab some testing utilities from the uvloop project). |
my understanding is that the PR in https://bugs.python.org/issue30698 fixes this issue no? If so can we get it merged? |
Andrew, Yury, PR 4402 is still open. Should the fix land in 3.7? I have removed the SSL component because it's not a bug in the ssl module. |
I'll take a look on the evening |
ping... |
Dima, we'll likely address this in 3.8, when we land new SSL implementation. Meanwhile you can use uvloop where all these bugs should be fixed. |
Since bpo-issue44011 is fixed, this can be closed now @asvetlov. |
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: